Commit c975ff41f41bebdec09901c364d2e9fe23193ba2

allow users to set their full/real name

Commit diff

app/controllers/accounts_controller.rb

 
1111 def update
1212 @user = current_user
1313 current_user.email = params[:user][:email] if params[:user][:email]
14 current_user.fullname = params[:user][:fullname] if params[:user][:fullname]
1415 current_user.password = params[:user][:password] if params[:user][:password]
1516 if params[:user][:password_confirmation]
1617 current_user.password_confirmation = params[:user][:password_confirmation]
toggle raw diff

app/views/accounts/edit.html.erb

 
66 <%= f.label :email -%><br />
77 <%= f.text_field :email, :class => "text" -%>
88 </p>
9 <p>
10 <%= f.label :fullname, "Realname" -%><br />
11 <%= f.text_field :fullname, :class => "text" -%>
12 </p>
913 <p>
1014 <%= f.label :password -%><br />
1115 <%= f.password_field :password, :class => "text" -%>
toggle raw diff

app/views/accounts/show.html.erb

 
11<% @page_title = "Account" -%>
22
3<h2>Account details</h2>
4<ul>
5 <li>username: <%= current_user.login -%></li>
6 <li>email: <%= current_user.email -%></li>
3<h2>Account details <small><%= link_to "edit", edit_account_path -%></small></h2>
4<ul class="infobox">
5 <li><strong>Realname:</strong>
6 <%= current_user.fullname.blank? ? "N/A" : h(current_user.fullname) -%></li>
7 <li><strong>Username:</strong> <%= link_to h(current_user.login), user_path(current_user) -%></li>
8 <li><strong>Email:</strong> <%=h current_user.email -%></li>
79</ul>
810
911<h3>Your SSH Keys:</h3>
1919<% content_for :sidebar do -%>
2020 <ul class="links">
2121 <li><%= link_to "+ Add SSH key", new_account_key_path -%></li>
22 <li><%= link_to "+ Change email or password", edit_account_path -%></li>
22 <li><%= link_to "+ Edit details", edit_account_path -%></li>
2323 </ul>
2424<% end -%>
toggle raw diff

app/views/users/show.html.erb

 
11<h1><%=h @user.login -%></h1>
22
33<ul class="infobox">
4 <li><strong>Username:</strong> <%= h(@user.login) -%></li>
5 <li><strong>Realname:</strong> <%= @user.fullname.blank? ? "N/A" : h(@user.fullname) -%></li>
46 <li><strong>Email:</strong> <%= encoded_mail_to(@user.email) -%></li>
57 <li><strong>Member for</strong> <%= time_ago_in_words(@user.created_at) -%></li>
68</ul>
toggle raw diff

db/migrate/013_add_fullname_to_users.rb

 
1class AddFullnameToUsers < ActiveRecord::Migration
2 def self.up
3 add_column :users, :fullname, :string
4 end
5
6 def self.down
7 remove_column :users, :fullname
8 end
9end
toggle raw diff

db/schema.rb

 
99#
1010# It's strongly recommended to check this file into your version control system.
1111
12ActiveRecord::Schema.define(:version => 12) do
12ActiveRecord::Schema.define(:version => 13) do
1313
1414 create_table "permissions", :force => true do |t|
1515 t.integer "user_id"
9191 t.string "activation_code", :limit => 40
9292 t.datetime "activated_at"
9393 t.integer "ssh_key_id"
94 t.string "fullname"
9495 end
9596
9697 add_index "users", ["login"], :name => "index_users_on_login"
toggle raw diff