Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # db/fixtures/roles.rb
- %w(admin normal guest).each do |r|
- Role.seed(:name) do |s|
- s.name = r
- end
- end
- # db/fixtures/users.rb
- admin_role = Role.find(:first, :conditions => "name = 'admin'")
- normal_role = Role.find(:first, :conditions => "name = 'normal'")
- guest_role = Role.find(:first, :conditions => "name = 'guest'")
- user = User.seed(:login, :email) do |s|
- s.login = "admin"
- s.email = "admin@example.com"
- s.first_name = "System"
- s.last_name = "Administrator"
- s.password = "admin"
- s.password_confirmation = "admin"
- end
- user.roles << admin_role
- user.roles << user_role
Add Comment
Please, Sign In to add comment