Skip to content
This repository

Add support Mass-Assignment Role of ActiveRecord #577

Closed
wants to merge 1 commit into from

8 participants

Evgeniy Shurmin David Singer Rebecca Skinner Piotr Gęga Dennis Riehle Jeremy Friesen Anuj Dutta Rene van Lieshout
Evgeniy Shurmin

No description provided.

Sijawusz Pur Rahnama Sija referenced this pull request from a commit in Sija/cancan
Sijawusz Pur Rahnama Sija Merged PR #577 b29c5d3
David Singer

I ran into this problem as well.. now that attr_accessible takes an :as option it seems like this is an important fix. Any chance of getting it rolled up into the gem?

David Singer ramaboo referenced this pull request from a commit
David Singer ramaboo fixing #577 d4bd399
Rebecca Skinner

+1 for adding this!

Piotr Gęga
Dennis Riehle
driehle commented

+1 would like to see this in cancan!

Jeremy Friesen
Collaborator
jeremyf commented

@ramaboo I ran the tests and they do not pass on master branch. I'd imagine with a month passing there may be an API change.

Also please remove the white space at the end of # Passing to ActiveRecord for support Mass-Assignment Role in lib/cancan/controller_additions.rb

Hit me up when you get this working.

Anuj Dutta
Collaborator

Can someone write specs around this behaviour? It won't be merged into master without specs. Thanks.

Rene van Lieshout

Written some specs for this in #657

Anuj Dutta
Collaborator

Hello all, I am closing this pull request as @rvanlieshout has updated the pull request with some specs. Let's carry on a discussion there (#657).

Anuj Dutta andhapp closed this
Anuj Dutta andhapp referenced this pull request from a commit
David Singer ramaboo fixing #577 4f1893f
Anuj Dutta andhapp referenced this pull request from a commit
David Singer ramaboo fixing #577 9ff47ea
Deleted user Unknown referenced this pull request from a commit in bignerdranch/cancan
David Singer ramaboo fixing #577 e3c0992
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 08, 2012
Evgeniy Shurmin jpascal Add option :assigment to load_and_authorize_resource for support Mass…
…-Assignment Role of ActiveRecord
9b41fca
This page is out of date. Refresh to see the latest.
3  lib/cancan/controller_additions.rb
@@ -112,6 +112,9 @@ 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
  117 + #
115 118 def load_resource(*args)
116 119 cancan_resource_class.add_before_filter(self, :load_resource, *args)
117 120 end
2  lib/cancan/controller_resource.rb
@@ -82,7 +82,7 @@ def load_collection
82 82 end
83 83
84 84 def build_resource
85   - resource = resource_base.new(@params[name] || {})
  85 + resource = resource_base.new(@params[name] || {}, :as => @options[:assignment])
86 86 resource.send("#{parent_name}=", parent_resource) if @options[:singleton] && parent_resource
87 87 initial_attributes.each do |attr_name, value|
88 88 resource.send("#{attr_name}=", value)

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.