added motivation header

This commit is contained in:
nilsding 2014-11-29 22:34:11 +01:00
parent 40f0e87fdc
commit 685b0efe83
5 changed files with 15 additions and 4 deletions

View File

@ -10,9 +10,9 @@ class UserController < ApplicationController
def update
authenticate_user!
user_attributes = params.require(:user).permit(:display_name)
user_attributes = params.require(:user).permit(:display_name, :motivation_header)
unless current_user.update_attributes(user_attributes)
flash[:error] = "fork it"
flash[:error] = 'fork it'
end
redirect_to edit_user_profile_path
end

View File

@ -1,7 +1,10 @@
.panel.panel-default
.panel-heading
%h3.panel-title
- if @user.motivation_header.blank?
Ask something!
- else
= @user.motivation_header
.panel-body
#question-box
.row

View File

@ -7,4 +7,6 @@
= f.text_field :display_name, label: "Your name"
= f.text_field :motivation_header, label: "Motivation header"
= f.submit "Save settings", class: 'btn btn-primary'

View File

@ -0,0 +1,5 @@
class AddMotivationHeaderToUsers < ActiveRecord::Migration
def change
add_column :users, :motivation_header, :string, default: '', null: false
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20141126154451) do
ActiveRecord::Schema.define(version: 20141129211448) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -81,6 +81,7 @@ ActiveRecord::Schema.define(version: 20141126154451) do
t.string "display_name"
t.integer "smiled_count", default: 0, null: false
t.boolean "admin", default: false, null: false
t.string "motivation_header", default: "", null: false
end
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree