Notes posted by danwich
RSS feed
danwich -
January 16, 2012
0 thanks
link_to with :as routing
The following will not work when your post model is routed with the :as option:
link_to("View post", @post)
Instead, use the helper with your custom name:
link_to("View post", :url => renamedpost_path(@post))
danwich -
January 16, 2012
0 thanks
form_for with :as routing
The following will not work if your post model is routed with the :as option:
form_for(@post)
Instead, use the helper with your custom name:
form_for(@post, :url => edit_renamedpost_path(@post))
danwich -
January 16, 2012
1 thank
Model objects routed with :as
When providing a model object, url_for will not work if the model’s routes are named using the :as option. You can instead use the named helper methods (posts_path, post_path(:id), etc.).