Make the first user as admin,user with id =1
This commit is contained in:
parent
f6e60823a7
commit
817861a5e4
3 changed files with 9 additions and 13 deletions
|
|
@ -10,7 +10,7 @@ class User < ActiveRecord::Base
|
|||
has_and_belongs_to_many :roles
|
||||
has_one :person, :inverse_of => :user
|
||||
|
||||
attr_accessible :email, :password, :password_confirmation, :remember_me, :role_id, :role_ids, :person_attributes,:confirmed_at
|
||||
attr_accessible :email, :password, :password_confirmation, :remember_me, :role_id, :role_ids, :person_attributes
|
||||
accepts_nested_attributes_for :person
|
||||
accepts_nested_attributes_for :roles
|
||||
|
||||
|
|
@ -27,9 +27,13 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def setup_role
|
||||
if self.id == 1
|
||||
self.role_ids = [3]
|
||||
end
|
||||
|
||||
if self.role_ids.empty?
|
||||
self.role_ids = [1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def popup_details
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue