Namespace Route and Form_for Method

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

1
2
3
  map.namespace :admin do |admin|
    admin.resources :users
  end

And you like to have a form like this:

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

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

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

This might save you some time. ;-)

Comments

Copyright © 2013 - Tom Pesman - Powered by Octopress