Name Controller Redirected URLs

I probably have a simple question. I created a namespace panelwith a controller categories.

After creating or editing a category, the rails redirect me to website.com/categories/:idinstead website.com/panel/categories/:id.

I noticed that in the representation _form argument @panel_categoriesfunction form_for()indicates /categoriesand /panel/categoriesand causes this behavior. Offcourse I can add a parameter :url => '/panel/categories', but I feel that this is not the best solution ...

Can you provide me a 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

form:

http://pastebin.com/HGmkZZHM

+3
source share
2 answers
form_for [:panel, @panel_category]
+2

URL- , :

:url => panel_categories_path

, , .

0

All Articles