Advertisement
Guest User

Untitled

a guest
Jan 19th, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. # lib/tasks/reset_permissions.rb
  2.  
  3. namespace :db do
  4. desc "Setup the Roles database to provision permissions properly"
  5. task :permissions => :environment do
  6. delete_old_permissions
  7. make_roles
  8. assign_roles
  9. end
  10. end
  11.  
  12.  
  13. def delete_old_permissions
  14. Role.delete_all
  15. Right.delete_all
  16. Grant.delete_all
  17. Assignment.delete_all
  18. end
  19.  
  20.  
  21. def make_roles
  22. @communications_role = Role.create!(:name => 'communications')
  23. @communications_role.rights.create!(:resource => "users", :operation => "READ")
  24. @communications_role.rights.create!(:resource => "news_posts", :operation => "READ")
  25. @communications_role.rights.create!(:resource => "news_posts", :operation => "UPDATE")
  26. @communications_role.rights.create!(:resource => "news_posts", :operation => "CREATE")
  27. @communications_role.rights.create!(:resource => "news_posts", :operation => "DELETE")
  28. @communications_role.rights.create!(:resource => "news_blasts", :operation => "READ")
  29. @communications_role.rights.create!(:resource => "news_blasts", :operation => "UPDATE")
  30. @communications_role.rights.create!(:resource => "news_blasts", :operation => "CREATE")
  31. @communications_role.rights.create!(:resource => "news_blasts", :operation => "DELETE")
  32. @communications_role.rights.create!(:resource => "bio_records", :operation => "READ")
  33. @communications_role.rights.create!(:resource => "bio_records", :operation => "UPDATE")
  34. @communications_role.rights.create!(:resource => "bio_records", :operation => "CREATE")
  35. @communications_role.rights.create!(:resource => "bio_records", :operation => "DELETE")
  36.  
  37.  
  38. @management_role = Role.create!(:name => 'management')
  39. #@management_role.rights.create!(:resource => "users", :operation => "READ")
  40. #@management_role.rights.create!(:resource => "users", :operation => "UPDATE")
  41. #@management_role.rights.create!(:resource => "users", :operation => "CREATE")
  42. #@management_role.rights.create!(:resource => "users", :operation => "DELETE")
  43. puts "i'm about to do the thing I've been trying to add to this file..."
  44. @management_role.rights.create!(:resource => "real_time_interaction", :operation => "READ")
  45.  
  46. @customer_role = Role.create!(:name => 'customer')
  47. @customer_role.rights.create!(:resource => "users", :operation => "READ")
  48. end
  49.  
  50. def assign_roles
  51. .
  52. .
  53. .
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement