initialise attributes after a resource is created by an InheritedResources controller

This commit is contained in:
mccraig mccraig of the clan mccraig 2012-01-11 17:23:35 +00:00 committed by Anuj Dutta
parent 7bf683d8f4
commit c2c0b86c3a

View File

@ -6,7 +6,13 @@ module CanCan
@controller.send :association_chain @controller.send :association_chain
@controller.instance_variable_get("@#{instance_name}") @controller.instance_variable_get("@#{instance_name}")
elsif new_actions.include? @params[:action].to_sym elsif new_actions.include? @params[:action].to_sym
@controller.send :build_resource
resource = @controller.send :build_resource
initial_attributes.each do |attr_name, value|
resource.send("#{attr_name}=", value)
end
resource
else else
@controller.send :resource @controller.send :resource
end end