Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Rename :assignment option to :assign_as

  • Loading branch information...
commit de2d208ddfcf1f35d0e559e7c26ed331b0678016 1 parent c60a13f
Martijn Storck authored June 19, 2012
4  lib/cancan/controller_additions.rb
@@ -112,8 +112,8 @@ def load_and_authorize_resource(*args)
112 112
       # [:+prepend+]
113 113
       #   Passing +true+ will use prepend_before_filter instead of a normal before_filter.
114 114
       #
115  
-      # [:+assignment+]
116  
-      #   Passing to ActiveRecord for support Mass-Assignment Role
  115
+      # [:+assign_as+]
  116
+      #   Passed as the role when mass assigning attributes (from Rails 3.1 onwards)
117 117
       #
118 118
       def load_resource(*args)
119 119
         cancan_resource_class.add_before_filter(self, :load_resource, *args)
6  lib/cancan/controller_resource.rb
@@ -82,9 +82,9 @@ def load_collection
82 82
     end
83 83
 
84 84
     def build_resource
85  
-      # use Rails 3.1's assign_attribute when resource_params[:assignment] is present
86  
-      if @options && @options[:assignment].present? && (resource = resource_base.new).respond_to?(:assign_attributes)
87  
-        resource.assign_attributes(resource_params || {}, :as => @options[:assignment])
  85
+      # use Rails 3.1's assign_attribute when resource_params[:assign_as] is present
  86
+      if @options && @options[:assign_as].present? && (resource = resource_base.new).respond_to?(:assign_attributes)
  87
+        resource.assign_attributes(resource_params || {}, :as => @options[:assign_as])
88 88
       else
89 89
         resource = resource_base.new(resource_params || {})
90 90
       end
4  spec/cancan/controller_resource_spec.rb
@@ -493,9 +493,9 @@ class Project < ::Project; end
493 493
         project.secret.should be_false
494 494
       end
495 495
 
496  
-      it "should be able to mass assign secret when using assignment" do
  496
+      it "should be able to mass assign secret when using :assign_as" do
497 497
         @params.merge!(:action => "create", :project => { :name => "foobar", :secret => "1" })
498  
-        resource = CanCan::ControllerResource.new(@controller, :assignment => :admin)
  498
+        resource = CanCan::ControllerResource.new(@controller, :assign_as => :admin)
499 499
         resource.load_resource
500 500
 
501 501
         project = @controller.instance_variable_get(:@project)

0 notes on commit de2d208

Please sign in to comment.
Something went wrong with that request. Please try again.