Skip to content

Instantly share code, notes, and snippets.

@roychri
Created November 30, 2012 18:50
Show Gist options
  • Save roychri/4177698 to your computer and use it in GitHub Desktop.
Save roychri/4177698 to your computer and use it in GitHub Desktop.
dynamic path helpers with an ActiveRecord object.
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