Created
October 18, 2010 17:21
-
-
Save voxik/632619 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From c3392a1440b4a341879b3f2665a8bf63eebeeb77 Mon Sep 17 00:00:00 2001 | |
| From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <[email protected]> | |
| Date: Mon, 18 Oct 2010 19:18:01 +0200 | |
| Subject: [PATCH] Pass parameters into contstructor. This should play better with default scaffolded RSpec test. | |
| --- | |
| lib/cancan/controller_resource.rb | 9 +++------ | |
| 1 files changed, 3 insertions(+), 6 deletions(-) | |
| mode change 100644 => 100755 lib/cancan/controller_resource.rb | |
| diff --git a/lib/cancan/controller_resource.rb b/lib/cancan/controller_resource.rb | |
| old mode 100644 | |
| new mode 100755 | |
| index 91878c0..3f21b43 | |
| --- a/lib/cancan/controller_resource.rb | |
| +++ b/lib/cancan/controller_resource.rb | |
| @@ -61,12 +61,9 @@ module CanCan | |
| end | |
| def build_resource | |
| - resource = resource_base.send(@options[:singleton] ? "build_#{name}" : "new") | |
| - initial_attributes.each do |name, value| | |
| - resource.send("#{name}=", value) | |
| - end | |
| - resource.attributes = @params[name] if @params[name] | |
| - resource | |
| + method_name = @options[:singleton] ? "build_#{name}" : "new" | |
| + resource_params = initial_attributes.merge(@params[name] || {}) | |
| + resource_base.send(*[method_name, resource_params]) | |
| end | |
| def initial_attributes | |
| -- | |
| 1.7.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment