Permalink
Browse files

Rename :assignment option to :assign_as

  • Loading branch information...
martijn authored and andhapp committed Jun 19, 2012
1 parent b99d5b2 commit 2b660d7b637f4118fec3170ee76b63db1a17d5c8
@@ -112,8 +112,8 @@ def load_and_authorize_resource(*args)
# [:+prepend+]
# Passing +true+ will use prepend_before_filter instead of a normal before_filter.
#
- # [:+assignment+]
- # Passing to ActiveRecord for support Mass-Assignment Role
+ # [:+assign_as+]
+ # Passed as the role when mass assigning attributes (from Rails 3.1 onwards)
#
def load_resource(*args)
cancan_resource_class.add_before_filter(self, :load_resource, *args)
@@ -82,9 +82,9 @@ def load_collection
end
def build_resource
- # use Rails 3.1's assign_attribute when resource_params[:assignment] is present
- if @options && @options[:assignment].present? && (resource = resource_base.new).respond_to?(:assign_attributes)
- resource.assign_attributes(resource_params || {}, :as => @options[:assignment])
+ # use Rails 3.1's assign_attribute when resource_params[:assign_as] is present
+ if @options && @options[:assign_as].present? && (resource = resource_base.new).respond_to?(:assign_attributes)
+ resource.assign_attributes(resource_params || {}, :as => @options[:assign_as])
else
resource = resource_base.new(resource_params || {})
end
@@ -507,9 +507,9 @@ class Section
project.secret.should be_false
end
- it "should be able to mass assign secret when using assignment" do
+ it "should be able to mass assign secret when using :assign_as" do
@params.merge!(:action => "create", :project => { :name => "foobar", :secret => "1" })
- resource = CanCan::ControllerResource.new(@controller, :assignment => :admin)
+ resource = CanCan::ControllerResource.new(@controller, :assign_as => :admin)
resource.load_resource
project = @controller.instance_variable_get(:@project)

0 comments on commit 2b660d7

Please sign in to comment.