Permalink
Browse files

initialise attributes after a resource is created by an InheritedReso…

…urces controller
  • Loading branch information...
1 parent 7bf683d commit c2c0b86c3a6ded6fb8ccbd85d2faa5e2221d5c23 @mccraigmccraig mccraigmccraig committed with andhapp Jan 11, 2012
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/cancan/inherited_resource.rb
@@ -6,7 +6,13 @@ def load_resource_instance
@controller.send :association_chain
@controller.instance_variable_get("@#{instance_name}")
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
@controller.send :resource
end

0 comments on commit c2c0b86

Please sign in to comment.