Making initial changes to add authorize after update

This commit is contained in:
Will Bradley 2013-06-28 23:34:07 -04:00
parent f2f40c7aac
commit acc76446c5

View File

@ -24,6 +24,10 @@ module CanCan
def load_and_authorize_resource
load_resource
authorize_resource
if update_actions.include?(@params[:action].to_sym)
update_resource
authorize_resource # Reauthorize the now-updated resource
end
end
def load_resource
@ -86,6 +90,10 @@ module CanCan
assign_attributes(resource)
end
def update_resource
resource.assign_attributes(resource_params || {})
end
def assign_attributes(resource)
resource.send("#{parent_name}=", parent_resource) if @options[:singleton] && parent_resource
initial_attributes.each do |attr_name, value|
@ -252,6 +260,10 @@ module CanCan
[:new, :create] + [@options[:new]].flatten
end
def update_actions
[:update] #TODO: check what @options is for
end
private
def extract_key(value)