Only One Controller + Urgent

What is the first step you are describing here .. ?
i did not get it properly .. ?

Älphä Blüë wrote:

Hemant Bhargava wrote:

Hi Champs,

Need Help .. :frowning:

Actually the thing is that i am having many controllers a, b, c and d..
But what i want it that only "a" should be displayed to the users .. b,
c, d not ..
Is there any way to do it .. ?

Cheers ..

Yes, you can do this a couple of ways..

The first way is you can inhibit the routing of controllers you don't
want people to access by doing something similar:

In Which controller or config/routes.rb file ..

First, how are you creating these controllers? Are you creating them
RESTfully? Are you using generate controller or generate scaffold?

If you are generating via scaffold then inside your routes.rb file
you'll see something like:

map.resources :controller

Mapping is what creates the routes for this. Keep in mind that at the
bottom of that file you may have:

map.connect ':controller/:action/:id'
map.connect ':controller/action/id.:format'

These two lines basically setup the controller, action, id routing to
every controller you create. If you don't want these to manage those
routes you need to comment them out:

# map.connect ':controller/:action/:id'
# map.connect ':controller/action/id.:format'

Then, you setup explicit routing using the examples I gave. If you are
having trouble with routes then you need to research them a bit and get
familiar with them. They are very important for working with rails:

http://guides.rubyonrails.org/routing.html

Can i do this thing in config/routes.rb ..?
If yes .. How can i .. ?

Hemant Bhargava wrote:

quite interesting problem
   I think best way to add :before_filter to your controllers

routing will restrict even the admin level user to access the
controllers.

if you want to restrict all users including the admin then you have to
think how
can you access that controller from the internal system (because if
you are
using restful routing and have not define anything for that controller
then you will not be able to
access those controller. in that case you have to rethink about the
design i mean whether you really need those controllers)

if this one is the authorization problem then :before_filter is the
best solution