-
-
Save ecnalyr/8ff0a7cc8b18e16c3b2a 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
# needs to return either a blank array or an array of place_preferences | |
def current_place_preferences | |
if PlacePreference.where(venue_uuid: current_place.id).blank? | |
[] | |
else | |
# restrict list if there is a role involved | |
if current_user.roles.present? | |
place_preferences = [] | |
current_user.roles.each do |role| | |
if role.place_preference.present? && role.place_preference.venue_uuid == current_place.id | |
place_preferences << role.place_preference | |
end | |
end | |
return place_preferences if place_preferences.present? | |
end | |
# fallback if the user has no roles | |
PlacePreference.where(venue_uuid: current_place.id) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment