Skip to content

Instantly share code, notes, and snippets.

@slashmili
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save slashmili/87abbf74e8020ca7e95c to your computer and use it in GitHub Desktop.

Select an option

Save slashmili/87abbf74e8020ca7e95c to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
has_many :memberships
has_many :boards, through: :memberships
end
class Board < ActiveRecord::Base
has_many :memberships
end
class Membership < ActiveRecord::Base
belongs_to :user
belongs_to :board
def role
return :admin if role_mask == 1
return :member if role_mask == 4
end
end
#how can I get here ?
current_user.boards[0].role
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment