[Rails] Re: Scaffolding - disabling Create, Edit, Destroy for some u

Kevin Olbrich kevin.olbrich at duke.edu
Tue Jan 10 01:19:47 GMT 2006


Francois Beausoleil wrote:
> Hello Philip !
> 
> 2006/1/9, Philip Rhoades <phil at pricom.com.au>:
>> but is there some way that I can disable Create, Edit, Destroy for some
>> user logins in the corresponding view?
> 
> Yes, just use link_to_if instead of link_to in the views:
> 
> <%= link_to_if current_user.login == 'admin', 'Create', :action => 
> 'create' %>
> 
> Of course, any condition is possible.
> 
> Hope that helps !

That doesn't disable the action, it just makes it inconvenient to use.

The simple way to disable it for a given user would be to create another 
before filter.  Have it check to see if the user has access to that 
action based on some criteria.  If they don't, redirect to a safe 
action.

_Kevin

-- 
Posted via http://www.ruby-forum.com/.


More information about the Rails mailing list