Guest User

Untitled

a guest
Mar 6th, 2018
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. # db/fixtures/roles.rb
  2.  
  3. %w(admin normal guest).each do |r|
  4. Role.seed(:name) do |s|
  5. s.name = r
  6. end
  7. end
  8.  
  9. # db/fixtures/users.rb
  10.  
  11. admin_role = Role.find(:first, :conditions => "name = 'admin'")
  12. normal_role = Role.find(:first, :conditions => "name = 'normal'")
  13. guest_role = Role.find(:first, :conditions => "name = 'guest'")
  14.  
  15. user = User.seed(:login, :email) do |s|
  16. s.login = "admin"
  17. s.email = "admin@example.com"
  18. s.first_name = "System"
  19. s.last_name = "Administrator"
  20. s.password = "admin"
  21. s.password_confirmation = "admin"
  22. end
  23.  
  24. user.roles << admin_role
  25. user.roles << user_role
Add Comment
Please, Sign In to add comment