resources_controller
resources_controller copied to clipboard
Use resource or @resource in before_filter
Is there a way to use the @resource that is created or the resource method in a before_filter?
I checked a little deeper and found that all actions call find_resource themselves.. instead it would be nice to have a before_filter :find_resource, :only => [:show, :edit, :update, :destroy]
This would make it possible to do some extra checks in a before_filter like:
before_filter :check_if_owner_of_resource
def check_if_owner_of_resource
redirect_to root_path, :notice => "You are not the owner" unless resource.user == current_user
end
Hi,
I'm currently on holiday until the 1st May. I'll look at this after then.
Cheers, Ian White
Sent from my iPhone
On 21 Apr 2011, at 14:55, [email protected] wrote:
Is there a way to use the @resource that is created or the resource method in a before_filter?
Reply to this email directly or view it on GitHub: https://github.com/ianwhite/resources_controller/issues/4
Any news here? This would be very handy.