Last active
April 27, 2017 19:29
-
-
Save flash-gordon/96020d4c21a0ad7754f56b6b6c983efd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Jobs < ROM::Relation[:sql] | |
schema(:jobs) do | |
# ... | |
associations do | |
belongs_to :team | |
belongs_to :template | |
belongs_to :address | |
belongs_to :client | |
end | |
end | |
view(:index) do | |
schema do | |
append( | |
relations[:references][:code].as(:type_code), | |
relations[:teams][:name].as(:team_name), | |
relations[:templates][:name].as(:template_name), | |
relations[:addresses][:formatted].as(:formatted_address), | |
relations[:clients][:name].as(:client_name) | |
).qualified | |
end | |
relation do |tenant_id| | |
where(self[:tenant_id].qualified.is(tenant_id)) | |
.left_join(teams) | |
.left_join(templates) | |
.left_join(addresses) | |
.left_join(clients) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment