Automatic route match for home and admin

I am trying to avoid having to type each controller path manually and
use the match as in here: ‘:controller(/:action(/:id))(.:format)’. So I
commented out all the manually routes and uncommented the match rule
down at the bottom of routes.rb.

It works for home controllers, but not the ones located at the admin
folder.

I tried modifying the match rule to include the “admin” path, but with
no success:

I keep getting this error:
No route matches [GET] “/admin/shop_services_configurator/index”

Look what I am trying to do:
match ‘/admin/:controller(/:action(/:id))(.:format)’

My goal is to have just two rules: one for home and one for admin.

Is it possible?
thanks

Kopy::Application.routes.draw do

home area

get “home/index”

get “my_account/index”

get “users/edit”

get “users/update”

put “users/update”

get “addresses/list”

get “addresses/edit”

get “addresses/delete”

put “addresses/update”

admin area

get “admin/shop_services_configurator/index”

post “admin/shop_services_configurator/create”

post “admin/shop_services_configurator/update”

#get “admin/shop_services_configurator/create”

get “admin/my_account/index”

post “admin/shop_users/create”

get “admin/shop_users/new”

post “admin/shop_users/new”

get “admin/shop_users/create”

get “admin/shop_services/create”

get “admin/shop_services/list”

post “admin/shop_services/list”

post “admin/shop_services/create”

get “shop_users/new”

get “shops/list”

post “shop_users/create”

get “greetings/hello”

post “admin/users/create”

get “admin/users/list”

get “admin/users/show”

get “admin/users/edit”

post “admin/users/edit”

get “admin/users/delete”

post “admin/users/delete”

put “admin/users/update”

get “admin/users/new”

post “admin/users/new”

get “admin/home/index”

get “categories/index”

get “categories/list”

get “access/login”

get “access/clear”

post “access/attempt_login”

get “admin/shops/edit”

get “admin/shops/update”

put “admin/shops/update”

get “javascripts/dynamic_states”

get “javascripts/index”

get “admin/discounts/index”

get “admin/selected_services/list”

root to: ‘home#index’

The priority is based upon order of creation:

first created -> highest priority.

Sample of regular route:

match ‘products/:id’ => ‘catalog#view’

Keep in mind you can assign values other than :controller and

:action

Sample of named route:

match ‘products/:id/purchase’ => ‘catalog#purchase’, :as =>

:purchase

This route can be invoked with purchase_url(:id => product.id)

Sample resource route (maps HTTP verbs to controller actions

automatically):

resources :products

Sample resource route with options:

resources :products do

member do

get ‘short’

post ‘toggle’

end

collection do

get ‘sold’

end

end

Sample resource route with sub-resources:

resources :products do

resources :comments, :sales

resource :seller

end

Sample resource route with more complex sub-resources

resources :products do

resources :comments

resources :sales do

get ‘recent’, :on => :collection

end

end

Sample resource route within a namespace:

namespace :admin do

# Directs /admin/products/* to Admin::ProductsController

# (app/controllers/admin/products_controller.rb)

resources :products

end

You can have the root of your site routed with “root”

just remember to delete public/index.html.

root :to => ‘welcome#index’

See how all your routes lay out with “rake routes”

This is a legacy wild controller route that’s not recommended for

RESTful applications.

Note: This route will make all actions in every controller

accessible via GET requests.

namespace “admin” do
resources :shop_services_configurator_controller, :users
end

match ‘:controller(/:action(/:id))(.:format)’

end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs