Resourceful routing and admin namespace question

7 views
Skip to first unread message

Agis A.

unread,
Mar 2, 2012, 6:57:11 AM3/2/12
to rubyonra...@googlegroups.com
Hi all. I have a route file like this:

Deals::Application.routes.draw do
  root to: "Main#home"

  resources :vendors do
    resources :offers
  end

  match '/admin' => 'Admin::Pages#index'

  namespace :admin do
    match '/login', to: 'Sessions#new'
    resources :offers, :vendors
    resources :sessions, only: [:new, :create, :destroy]
  end
end

First of all I would like to know if the way I declared the namespace and the matching rules inside it are ok.

Next, I want the visitors of the app (front-end) to be able only to view the :offers and :vendor resources (index & show actions). I only want to allow admins (app.com/admin/blabla) which are the logged users, to be able to manage these resources (edit, add, delete etc). How could I implement this?

Should I do it like this? http://pastie.org/3503560 Or could I just leave it as is and not implement the actions in the public controllers?
Reply all
Reply to author
Forward
0 new messages