This project is archived and is in readonly mode.
Using form_for() with :as option in routes breaks
-
Andrew White
- State changed from new to invalid
- Assigned user cleared.
- Importance changed from to Low
Using :as in a resources call doesn't change the name of a model throughout your application. You need to use the url helper in form_for:
<%= form_for(@post, :url => articles_path) do %> <!-- form contents --> <% end %> -
Nick Kezhaya
This becomes problematic if you'd want to use a partial (
_form.html.erb).<%= form_for(@post, :url => articles_path) do %> <!-- form contents --> <% end %>This only works if you're trying to create a new Post object. To edit one, however, you'd need to supply
article_path(@post).This can become particularly messy if you were to do something like:
form_for(@post, :url => (action_name == 'edit') ? article_path(@post) : articles_path).