Friday, May 27, 2011

Re: [Rails] Re: Rails Routes/Controller/Directory Structure design question



On Fri, May 27, 2011 at 9:11 PM, egervari <ken.egervari@gmail.com> wrote:
How do you deal with form_for's when the routes are nested?

For example, let's say you have a Admin::CompaniesController in
your :admin namespace. The model is obviously Company. I get an error
for new forms:

   <%= simple_form_for(@company, :url =>
admin_company_path(@company)) do |f| %>

Here's the error message:

   ActionView::Template::Error: No route matches
{:action=>"show", :controller=>"admin/companies", :id=>#<Company id:
nil, name: nil, phone_number: nil, address: nil, postal_code: nil,
is_enabled: true, courses_created: 0, province_id: nil, theme_id: nil,
payment_plan_id: nil, created_at: nil, updated_at: nil>}

How can I get rails to play nice? I have no idea why it's even trying
to use the show action at all...

Try running rake routes and see what you get.... then either use what you have available or modify so you have the route you want.
 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate