finally, setting the display_name works.

This commit is contained in:
nilsding 2014-11-11 20:20:00 +01:00
parent 550824e287
commit fb48c6d995
3 changed files with 8 additions and 5 deletions

View File

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

View File

@ -15,7 +15,9 @@ class User < ActiveRecord::Base
SCREEN_NAME_REGEX = /\A[a-zA-Z0-9_]{1,16}\z/ SCREEN_NAME_REGEX = /\A[a-zA-Z0-9_]{1,16}\z/
validates :screen_name, presence: true, format: { with: SCREEN_NAME_REGEX }, uniqueness: { case_sensitive: false } validates :screen_name, presence: true, format: { with: SCREEN_NAME_REGEX }, uniqueness: { case_sensitive: false }
def login=(login) def login=(login)
@login = login @login = login
end end

View File

@ -3,7 +3,7 @@
.col-md-9.col-xs-12.col-sm-9 .col-md-9.col-xs-12.col-sm-9
.panel.panel-default .panel.panel-default
.panel-body .panel-body
= bootstrap_form_for(update_user_profile_path, method: "patch") do |f| = bootstrap_form_for(:user, method: "patch") do |f|
= f.text_field :display_name, label: "Your name" = f.text_field :display_name, label: "Your name"