i using devise , have
before_filter :authenticate_user!
on resource page, pages can created/updated registered user don't want specific user, :id = 22 not have thls. how ?
for example update code on pagecontroller
@page = page.find(params[:id])
so want make
if user.id != 22 @page = page.find(params[:id])
you may in pages controller by
if current_user , current_user.id != 22 ...
or before_filter
in pages controller by
before_filter :check_for_specific_user, :only => [:create, :update] def check_for_specific_user if current_user , current_user.id == 22 # redirect or end end
or may in application controller by
before_filter :check_for_specific_user def check_for_specific_user if params[:controller] == 'pages' , ['create', 'update'].include? params[:action] , current_user , current_user.id == 22 # redirect or end end
also idea have method in application controller like
def admin? current_user , current_user.id == 22 end
then in pages controller able write just
if admin? # ... end
Comments
Post a Comment