Guest User

Untitled

a guest
Jun 18th, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. From c3392a1440b4a341879b3f2665a8bf63eebeeb77 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <v.ondruch@gmail.com>
  3. Date: Mon, 18 Oct 2010 19:18:01 +0200
  4. Subject: [PATCH] Pass parameters into contstructor. This should play better with default scaffolded RSpec test.
  5.  
  6. ---
  7. lib/cancan/controller_resource.rb | 9 +++------
  8. 1 files changed, 3 insertions(+), 6 deletions(-)
  9. mode change 100644 => 100755 lib/cancan/controller_resource.rb
  10.  
  11. diff --git a/lib/cancan/controller_resource.rb b/lib/cancan/controller_resource.rb
  12. old mode 100644
  13. new mode 100755
  14. index 91878c0..3f21b43
  15. --- a/lib/cancan/controller_resource.rb
  16. +++ b/lib/cancan/controller_resource.rb
  17. @@ -61,12 +61,9 @@ module CanCan
  18. end
  19.  
  20. def build_resource
  21. - resource = resource_base.send(@options[:singleton] ? "build_#{name}" : "new")
  22. - initial_attributes.each do |name, value|
  23. - resource.send("#{name}=", value)
  24. - end
  25. - resource.attributes = @params[name] if @params[name]
  26. - resource
  27. + method_name = @options[:singleton] ? "build_#{name}" : "new"
  28. + resource_params = initial_attributes.merge(@params[name] || {})
  29. + resource_base.send(*[method_name, resource_params])
  30. end
  31.  
  32. def initial_attributes
  33. --
  34. 1.7.1
Add Comment
Please, Sign In to add comment