Created
September 19, 2014 01:25
-
-
Save zimkies/72ddbe56ea6433593eb7 to your computer and use it in GitHub Desktop.
The problem with separating out models into purely their own concerns
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
# FML You are joking right? | |
# THere has to be something wrong with this model. | |
def user_has_been_to_venue?(user, venue) | |
Reservation.joins("LEFT JOIN venues_tables ON venues_tables.id = reservations.table_id LEFT JOIN venues ON venues_tables.venue_id = venues.id LEFT JOIN groupers ON groupers.id = reservations.grouper_id LEFT JOIN crews ON crews.grouper_id = groupers.id LEFT JOIN users ON users.id = crews.leader_id") | |
.where("crews.leader_id = ?", user.id) | |
.where("venues.id = ?", venue.id).exists? | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
user.groupers.pluck(:venue_id).include? venue.id