Skip to content

Instantly share code, notes, and snippets.

@jerodsanto
Created July 26, 2010 20:14
Show Gist options
  • Save jerodsanto/491166 to your computer and use it in GitHub Desktop.
Save jerodsanto/491166 to your computer and use it in GitHub Desktop.
admin = Role.create(:title => "admin")
mike = User.create(:name => "mike")
# either
mike.roles << admin
# or
mike.roles.push admin
# or you can also go the other way
admin.users << mike
# or
admin.users.push mike
# a quick way to create a bunch of roles
['admin', 'worker', 'client'].each do |title|
Role.create(:title => title)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment