Making initial changes to add authorize after update
This commit is contained in:
parent
f2f40c7aac
commit
acc76446c5
|
@ -24,6 +24,10 @@ module CanCan
|
||||||
def load_and_authorize_resource
|
def load_and_authorize_resource
|
||||||
load_resource
|
load_resource
|
||||||
authorize_resource
|
authorize_resource
|
||||||
|
if update_actions.include?(@params[:action].to_sym)
|
||||||
|
update_resource
|
||||||
|
authorize_resource # Reauthorize the now-updated resource
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_resource
|
def load_resource
|
||||||
|
@ -86,6 +90,10 @@ module CanCan
|
||||||
assign_attributes(resource)
|
assign_attributes(resource)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_resource
|
||||||
|
resource.assign_attributes(resource_params || {})
|
||||||
|
end
|
||||||
|
|
||||||
def assign_attributes(resource)
|
def assign_attributes(resource)
|
||||||
resource.send("#{parent_name}=", parent_resource) if @options[:singleton] && parent_resource
|
resource.send("#{parent_name}=", parent_resource) if @options[:singleton] && parent_resource
|
||||||
initial_attributes.each do |attr_name, value|
|
initial_attributes.each do |attr_name, value|
|
||||||
|
@ -252,6 +260,10 @@ module CanCan
|
||||||
[:new, :create] + [@options[:new]].flatten
|
[:new, :create] + [@options[:new]].flatten
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_actions
|
||||||
|
[:update] #TODO: check what @options is for
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def extract_key(value)
|
def extract_key(value)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user