Skip to content

Instantly share code, notes, and snippets.

@edwardloveall
Last active July 20, 2019 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edwardloveall/1c87956a8c8761d1f637f54cec51886c to your computer and use it in GitHub Desktop.
Save edwardloveall/1c87956a8c8761d1f637f54cec51886c to your computer and use it in GitHub Desktop.
class Groups::Index < BrowserAction
route do
groups = GroupQuery.new.join_users
render Groups::IndexPage, groups: groups
end
end
class Group < BaseModel
table :groups do
column title : String
has_many users : User, through: :memberships
end
end
class Memebership < BaseModel
table :memeberships do
belongs_to group : Group
belongs_to user : User
end
end
class User < BaseModel
table :users do
# other columns
has_many groups : Group, through: :memberships
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment