Hi
I am having a problem with the form_for method in Rails. It is behaving strangely.
I have a route with a path prefix, something like:
map.resources :beers, :path_prefix => '/:brewery'
And I have a form like this (@beer.brewery is a string, just the name of the brewery):
<% form_for @beer, :url => { :brewery => @beer.brewery } do |form|
--some fields
<% end %>
It will set the action of the form to this for a new record.
/brewery_name/beers/new
and this for an existing record.
/brewery_name/beers/1/edit
Anyone knows why this happens or how to fix it?
--edit--
Right now I am solving this like this (for a new record):
<% form_for @beer, :url => beers_path(@beer.brewery) do |form| %>
and (for an edited record)
<% form_for @beer, :url => beer_path(@beer.brewery, @beer) do |form| %>
But I want to do it the same way for new and edit, if it is possible.
Cheers, Thijs.