Created
July 17, 2014 18:56
-
-
Save magicmarkker/925f603fa6ec5d8b29ac 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
# routes.rb | |
resources :committees, as: :workrooms, path: :workrooms do | |
resources :meetings, concerns: :bookable | |
end | |
# Generates | |
# workroom_meeting_book GET /workrooms/:workroom_id/meetings/:meeting_id/books/:id( | |
polymorphic_path([@workroom, @meeting, @book]) | |
# But since @workroom is really a Committee model | |
# It's generating: committee_meeting_book_path :( |
Actually, I don't think polymorphic_path
is using your routes at all. You would probably be better off not using it or living with what it gives you.
@r38y @workroom
is a Committee AR result, same with meeting and book, however, if I remove @workroom
it works because the other two models aren't aliased. @workroom
is really the committee.rb
model file, but I have it aliased in the routes file. The polymorphic_path
is what im using to redirect instead of having 5 if/else
redirects in all of my controllers.
Lame, trying to refactor all of these if/else
to get rid of some code smell
Fixed it by changing the route to this:
resources :workrooms, as: :committees
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What does
[@workroom, @meeting, @book]
come out as? Where doespolymorphic_path
come from?