Commit 115f6c107ef8deee52f10b39e5e7d08c8dd329db
Committed by
Parley
1 parent
f19d2ba5
Exists in
master
and in
5 other branches
more_inst_for_users: Add relation to institution and users.
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Showing
5 changed files
with
27 additions
and
2 deletions
Show diff stats
db/migrate/20140818195821_remove_institution_from_user.rb
0 → 100644
db/migrate/20140818200738_create_institution_user_relation_table.rb
0 → 100644
lib/ext/user.rb
@@ -2,7 +2,7 @@ require_dependency 'user' | @@ -2,7 +2,7 @@ require_dependency 'user' | ||
2 | 2 | ||
3 | class User | 3 | class User |
4 | 4 | ||
5 | - belongs_to :institution | 5 | + has_and_belongs_to_many :institutions |
6 | 6 | ||
7 | validate :email_different_secondary?, :email_has_already_been_used?, | 7 | validate :email_different_secondary?, :email_has_already_been_used?, |
8 | :secondary_email_format, :email_suffix_is_gov? | 8 | :secondary_email_format, :email_suffix_is_gov? |
lib/institution.rb
@@ -5,7 +5,7 @@ class Institution < ActiveRecord::Base | @@ -5,7 +5,7 @@ class Institution < ActiveRecord::Base | ||
5 | attr_accessible :name, :acronym, :unit_code, :parent_code, :unit_type, | 5 | attr_accessible :name, :acronym, :unit_code, :parent_code, :unit_type, |
6 | :juridical_nature, :sub_juridical_nature, :normalization_level, | 6 | :juridical_nature, :sub_juridical_nature, :normalization_level, |
7 | :version, :cnpj, :type, :governmental_power, :governmental_sphere | 7 | :version, :cnpj, :type, :governmental_power, :governmental_sphere |
8 | - has_many :users | 8 | + has_and_belongs_to_many :users |
9 | 9 | ||
10 | validates :name, :presence=>true, :uniqueness=>true | 10 | validates :name, :presence=>true, :uniqueness=>true |
11 | 11 |