diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -6,7 +6,8 @@ :redirect_to => { :action => :index } in_place_edit_for :user, :full_name - in_place_edit_for :user, :alias + in_place_edit_for :user, :alias_for_editing + in_place_edit_for :user, :email_for_editing def index @user = User.find(session[:user_id]) diff --git a/app/models/user.rb b/app/models/user.rb --- a/app/models/user.rb +++ b/app/models/user.rb @@ -28,7 +28,31 @@ self.roles.detect {|r| r.name == 'admin' } end -# protected + def email_for_editing + if self.email!=nil + self.email + else + "unknown" + end + end + + def email_for_editing=(e) + self.email=e + end + + def alias_for_editing + if self.alias!=nil + self.alias + else + "unknown" + end + end + + def alias_for_editing=(e) + self.alias=e + end + + protected def encrypt_new_password return if password.blank? self.salt = (10+rand(90)).to_s diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml --- a/app/views/users/index.html.haml +++ b/app/views/users/index.html.haml @@ -14,7 +14,10 @@ %td.uinfo= in_place_editor_field :user, 'full_name', {}, :rows => 1 %tr %th.uinfo Alias - %td.uinfo= in_place_editor_field :user, 'alias', {}, :rows => 1 + %td.uinfo= in_place_editor_field :user, 'alias_for_editing', {}, :rows => 1 + %tr + %th.uinfo E-mail + %td.uinfo= in_place_editor_field :user, 'email_for_editing', {}, :rows => 1 %tr %th.uinfo Password %td.uinfo diff --git a/db/migrate/012_add_email_to_users.rb b/db/migrate/012_add_email_to_users.rb new file mode 100644 --- /dev/null +++ b/db/migrate/012_add_email_to_users.rb @@ -0,0 +1,9 @@ +class AddEmailToUsers < ActiveRecord::Migration + def self.up + add_column :users, :email, :string + end + + def self.down + remove_column :users, :email + end +end diff --git a/db/schema.rb b/db/schema.rb --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 11) do +ActiveRecord::Schema.define(:version => 12) do create_table "languages", :force => true do |t| t.string "name", :limit => 10 @@ -85,6 +85,7 @@ t.string "hashed_password" t.string "salt", :limit => 5 t.string "alias" + t.string "email" end add_index "users", ["login"], :name => "index_users_on_login", :unique => true