I have users and projects scaffolds in my Rails project. I also have an admin controller and view that is only accessible to admin users. I want the index and create controller actions for the users and projects models to be only accessible to the admin view (using render :partial > 'index') but I do not want to let the visitors to the site to be able to type in http://railsapp.host/users and get the partial rendered. How do I achieve this?
TO clarify, my issue is not about the user role. I have authlogic with all the require_admin helpers but I dont even want an admin user to be able to access the index route for users directly from the browser. In effect I want to limit the index controller action only to the view code of admin#index like this:
<%= render '/users/index' %>
Ok, I should have said I was a relative noob to rails. I figured it out though. I thought the
actually goes through the
users#indexcode. I just figured out that it was just calling the partial under the views without going through the controller action. So I simply added this to theuserscontrollerAnd that seems to achieve the goal I was seeking.
Thanks for all your help.