Skip to content

Instantly share code, notes, and snippets.

@hoblin
Last active August 16, 2019 08:15
Show Gist options
  • Save hoblin/9e1fbb7219819fdc3d9b89d6c2e26bf5 to your computer and use it in GitHub Desktop.
Save hoblin/9e1fbb7219819fdc3d9b89d6c2e26bf5 to your computer and use it in GitHub Desktop.
class Permission < ApplicationRecord
has_many :roles through: :roles_permissions
end
class Role < ApplicationRecord
has_many :users through: :users_roles
has_many :permissions through: :roles_permissions
end
class RolesPermission < ApplicationRecord
belongs_to :role
belongs_to :permission
end
class User < ApplicationRecord
has_many :roles through: :users_roles
end
class UsersRole < ApplicationRecord
belongs_to :user
belongs_to :role
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment