Commit 70f9eff6ba46e59983e225f9df2a71a64f44c1a5
1 parent
149906fb
Exists in
master
and in
3 other branches
Fixing the user references
Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com
Showing
4 changed files
with
29 additions
and
15 deletions
Show diff stats
... | ... | @@ -0,0 +1,17 @@ |
1 | +class AddExtraFieldsToUser < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + change_table :users do |t| | |
4 | + t.string :secondary_email | |
5 | + t.references :institution | |
6 | + t.string :role | |
7 | + end | |
8 | + end | |
9 | + | |
10 | + def self.down | |
11 | + change_table :users do |t| | |
12 | + t.remove :secondary_email | |
13 | + t.remove_references :institution | |
14 | + t.remove :role | |
15 | + end | |
16 | + end | |
17 | +end | ... | ... |
db/migrate/20150408121921_add_extra_fields_to_gov_user.rb
... | ... | @@ -1,15 +0,0 @@ |
1 | -class AddExtraFieldsToGovUser < ActiveRecord::Migration | |
2 | - def self.up | |
3 | - change_table :users do |t| | |
4 | - t.string :secondary_email | |
5 | - t.string :role | |
6 | - end | |
7 | - end | |
8 | - | |
9 | - def self.down | |
10 | - change_table :users do |t| | |
11 | - t.remove :secondary_email | |
12 | - t.remove :role | |
13 | - end | |
14 | - end | |
15 | -end |
lib/ext/person.rb
... | ... | @@ -18,4 +18,14 @@ class Person |
18 | 18 | self.user.secondary_email = value unless self.user.nil? |
19 | 19 | end |
20 | 20 | |
21 | + def institutions | |
22 | + institutions = [] | |
23 | + unless self.user.institutions.nil? | |
24 | + self.user.institutions.each do |institution| | |
25 | + institutions << institution.name | |
26 | + end | |
27 | + end | |
28 | + institutions | |
29 | + end | |
30 | + | |
21 | 31 | end | ... | ... |
lib/ext/user.rb