Namespace route and form_for method

When you have a namespace in your routes.rb like this:

  map.namespace :admin do |admin|
    admin.resources :users
  end

And you like to have a form like this:

<% form_for(@user) do |f| %>
  <%= f.error_messages %>

Change the form_for in this and you're good to go!

<% form_for([:admin, @user]) do |f| %>
  <%= f.error_messages %>

This might save you some time. ;-)

 

1 comment

Constantine Maring 03 October 2011 at 22:21
Emo-guitar_normal

Thanks a lot.. It did save a lot of my time :)

Add your comment:

Please login through: