Description:
add_email_to_user, fix empty problem for_in_place_editing
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@42 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r18:d8813c40713d - - 5 files changed: 42 inserted, 4 deleted
@@ -0,0 +1,9 | |||||
|
|
1 | + class AddEmailToUsers < ActiveRecord::Migration | ||
|
|
2 | + def self.up | ||
|
|
3 | + add_column :users, :email, :string | ||
|
|
4 | + end | ||
|
|
5 | + | ||
|
|
6 | + def self.down | ||
|
|
7 | + remove_column :users, :email | ||
|
|
8 | + end | ||
|
|
9 | + end |
@@ -6,7 +6,8 | |||||
|
6 | :redirect_to => { :action => :index } |
|
6 | :redirect_to => { :action => :index } |
|
7 |
|
7 | ||
|
8 | in_place_edit_for :user, :full_name |
|
8 | in_place_edit_for :user, :full_name |
|
9 | - in_place_edit_for :user, :alias |
|
9 | + in_place_edit_for :user, :alias_for_editing |
|
|
10 | + in_place_edit_for :user, :email_for_editing | ||
|
10 |
|
11 | ||
|
11 | def index |
|
12 | def index |
|
12 | @user = User.find(session[:user_id]) |
|
13 | @user = User.find(session[:user_id]) |
@@ -28,7 +28,31 | |||||
|
28 | self.roles.detect {|r| r.name == 'admin' } |
|
28 | self.roles.detect {|r| r.name == 'admin' } |
|
29 | end |
|
29 | end |
|
30 |
|
30 | ||
|
31 | - # protected |
|
31 | + def email_for_editing |
|
|
32 | + if self.email!=nil | ||
|
|
33 | + self.email | ||
|
|
34 | + else | ||
|
|
35 | + "unknown" | ||
|
|
36 | + end | ||
|
|
37 | + end | ||
|
|
38 | + | ||
|
|
39 | + def email_for_editing=(e) | ||
|
|
40 | + self.email=e | ||
|
|
41 | + end | ||
|
|
42 | + | ||
|
|
43 | + def alias_for_editing | ||
|
|
44 | + if self.alias!=nil | ||
|
|
45 | + self.alias | ||
|
|
46 | + else | ||
|
|
47 | + "unknown" | ||
|
|
48 | + end | ||
|
|
49 | + end | ||
|
|
50 | + | ||
|
|
51 | + def alias_for_editing=(e) | ||
|
|
52 | + self.alias=e | ||
|
|
53 | + end | ||
|
|
54 | + | ||
|
|
55 | + protected | ||
|
32 | def encrypt_new_password |
|
56 | def encrypt_new_password |
|
33 | return if password.blank? |
|
57 | return if password.blank? |
|
34 | self.salt = (10+rand(90)).to_s |
|
58 | self.salt = (10+rand(90)).to_s |
@@ -14,7 +14,10 | |||||
|
14 | %td.uinfo= in_place_editor_field :user, 'full_name', {}, :rows => 1 |
|
14 | %td.uinfo= in_place_editor_field :user, 'full_name', {}, :rows => 1 |
|
15 | %tr |
|
15 | %tr |
|
16 | %th.uinfo Alias |
|
16 | %th.uinfo Alias |
|
17 | - %td.uinfo= in_place_editor_field :user, 'alias', {}, :rows => 1 |
|
17 | + %td.uinfo= in_place_editor_field :user, 'alias_for_editing', {}, :rows => 1 |
|
|
18 | + %tr | ||
|
|
19 | + %th.uinfo E-mail | ||
|
|
20 | + %td.uinfo= in_place_editor_field :user, 'email_for_editing', {}, :rows => 1 | ||
|
18 | %tr |
|
21 | %tr |
|
19 | %th.uinfo Password |
|
22 | %th.uinfo Password |
|
20 | %td.uinfo |
|
23 | %td.uinfo |
@@ -9,7 +9,7 | |||||
|
9 | # |
|
9 | # |
|
10 | # It's strongly recommended to check this file into your version control system. |
|
10 | # It's strongly recommended to check this file into your version control system. |
|
11 |
|
11 | ||
|
12 |
- ActiveRecord::Schema.define(:version => 1 |
|
12 | + ActiveRecord::Schema.define(:version => 12) do |
|
13 |
|
13 | ||
|
14 | create_table "languages", :force => true do |t| |
|
14 | create_table "languages", :force => true do |t| |
|
15 | t.string "name", :limit => 10 |
|
15 | t.string "name", :limit => 10 |
@@ -85,6 +85,7 | |||||
|
85 | t.string "hashed_password" |
|
85 | t.string "hashed_password" |
|
86 | t.string "salt", :limit => 5 |
|
86 | t.string "salt", :limit => 5 |
|
87 | t.string "alias" |
|
87 | t.string "alias" |
|
|
88 | + t.string "email" | ||
|
88 | end |
|
89 | end |
|
89 |
|
90 | ||
|
90 | add_index "users", ["login"], :name => "index_users_on_login", :unique => true |
|
91 | add_index "users", ["login"], :name => "index_users_on_login", :unique => true |
You need to be logged in to leave comments.
Login now