Created
December 26, 2013 12:44
-
-
Save elliot-nelson/8133418 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
# Don't do this... | |
my_url = @thing.new_record? ? new_thing_path : thing_path(@thing) | |
# Do this... | |
my_url = polymorphic_path(@thing) | |
# Especially useful for cases where you need to change the namespace or add extra params... | |
<%= form_for @thing %> | |
# Generates /things or /things/<id> | |
<%= form_for @thing, :url => polymorphic_path([:admin, @thing], :anchor => 'contact_form') do |f| %> | |
# Generates /admin/things#contact_form or /admin/things/<id>#contact_form | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment