Namespaced controller redirect urls

Posted by bajki on Stack Overflow See other posts from Stack Overflow or by bajki
Published on 2011-03-13T23:58:06Z Indexed on 2011/03/14 0:10 UTC
Read the original article Hit count: 194

Hello, i have probably a simple question. I have created a namespace panel with categories controller.

After creating or editing a category, rails redirects me to website.com/categories/:id instead of website.com/panel/categories/:id.

I've noticed that in the _form view, the @panel_categories argument of form_for() function points to /categories nor /panel/categories and that's causing this behaviour. Offcourse i can add a :url => '/panel/categories' param but i feel that it's not the best solution...

Can you provide me any better solution?

Thanks in advance

Files:

routes.rb:

Photowall::Application.routes.draw do
  resources :photos

  resources :categories

  resources :fields

  resources :users, :user_sessions
  match 'login'  => 'user_sessions#new',     :as => :login
  match 'logout' => 'user_sessions#destroy', :as => :logout

  namespace :panel do
    root :to => "photos#index"
    resources :users, :photos, :categories, :fields
  end

  namespace :admin do
    root :to => "users#index"
    resources :users, :photos, :categories, :fields
  end
end

categories_controller.rb:

http://pastebin.com/rWJykCCF

model is the default one

form:

http://pastebin.com/HGmkZZHM

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby