I am using the cancancan gem in my rails application. But I am not much clear for the meaning of load_and_authorize_resource
method. I know this is the same as calling load_resource
and authorize_resource
.
load_resource
will create a new instance of a model, or get a instance by params[:id]
, or a collection of instances, then authorize_resource
method will use these instances to authorize. But if I already have a Model.find(params[:id])
or Model.new
in each controller action, dose I need to add load_resource
method?
For some action(Non RESTful actions) , they don't have relationship with model, so I don't need to get a instance, for this situation, authorize_resource
how to work normally?
Any idea is appreciate! Thanks in advance!