Topic: form_for not working in another view

So I have a set of restful actions that allow a user to create a website model, has_one relationship, and pages models, has_many relationship. I have got the new/create, and edit/update working for both websites and pages models, but now I would like to move the edit/update actions onto one page. I would like to have the @page form on the website edit page, but when I put the same exact form_for which works in the pages edit.html.erb view into the website edit.html.erb view I get this error:

<%= form_for [@user,@website,@page], :url => user_websites_page_path do |f|  %>

produced

No route matches {:action=>"show", :controller=>"pages"}

which makes no sense to me since a form_for tag shouldn't be accessing the show action, and running rake routes does infact show a named route user_websites_page that matches page => show.

So, I then tried to specify the action, and method in different combinations to no avail.

The form_for code in the last, most specific version. but still not mapping to the right action.

<%= form_for [@user,@website,@page], :url => {:action => "update", :controller =>"pages"}, :html => {:method => :put} do |f|  %>
    <%= render 'shared/error_messages', :object => f.object %>
    ...
  
    <%= f.submit %>
<% end %>

any ideas how to get this to work?

Re: form_for not working in another view

so I found a not so elegant solution, I would still prefer a more direct way if anyone has one, but I used a literal string for the URL, and then used string interpolation to input the :id's

<%= form_for [@user,@website,@page], :url => "/users/#{@user.id}/websites/pages/#{@page.id}", :html => {:method => :put} do |f|  %>