Hemant Bhargava wrote:
> Hi Champs,
> 
> Need Help .. :(
> 
> 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:

Remove the routing to that controller completely OR
map.resources :controller_name, :only => :method_name

You could setup a catchall method using the above and have it redirect 
to some other controller etc...

OR

Place the following at the top of your controllers:

class YourController < ApplicationController
  before_filter :login_required, :authorize

  ...
end

.. which will force them to login and then it will call an authorize
function to check if they are an admin role..

Place the following in application_controller.rb

private

def authorize
  unless logged_in? && User.find(current_user).admin?
    redirect_to root_url
  end
end

.. and create an admin role on your users table
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to