Created
November 30, 2012 18:50
-
-
Save roychri/4177698 to your computer and use it in GitHub Desktop.
dynamic path helpers with an ActiveRecord object.
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
I have a controller/action with a helper path like this : | |
new_controller_path(:foo => {:record_type => 'Group', :record_id => group.id}) # This returns /foo/new?foo[record_type]=Group&foo[record_id]=123 which is what I want. | |
# I was hoping one of these two would return the SAME THING as above. | |
new_controller_path(Group.new(:record => group)) # This returns /foo/new but I want same thing as above. | |
new_controller_path(:foo => Group.new(:record => group)) # This returns /foo/new but I want same thing as above. | |
# My ultimate goal was to reduce the length of the helper line a bit. | |
# Thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment