I have a 'account roles' controller (for my AccountRole model) in my application using views generated by the standard scaffold generator. This controller is nested into my 'accounts' controller (for my Account model) using the following routing configuration:
resources :accounts do
resources :people, :controller => :account_roles
end
This results in routing helpers like account_people_path (/accounts/1/people) and account_person_path (/accounts/1/person/1). All well and good.
My problem comes in the default generated _form.html.erb partial. This file looks like this:
<%= form_for([@account,@account_role]) do |f| %>
<!-- Rest of form -->
<% end %>
I've customised this view to cope with the nested resources, but my use of the :controller option in my routing is causing me problems I think.
My view spec for the 'new' and 'edit' views (both of which use this partial) is resulting in the following error:
ActionView::Template::Error:
undefined method `account_account_role_path' for #<#<Class:0x105334360>:0x105300c18>
I think what's happening here is that form_for is trying to 'guess' the route helper for these resources. I know I could override the url by using the :url option to form_for, but that feels like a bit of a cop-out.
Am I missing an obvious solution to this that allows me to combine the :controller routing option with form_for's resource oriented style?