Skip to content

Custom attributes not being updated after active_record mass update changes #13

wants to merge 2 commits into from

4 participants

duksis commented Feb 15, 2012

After latest changes to active record mass update enqueuing jobs in DelayedJob tables with custom fields failed with

   Can't mass-assign protected attributes: .....

or just did not populate custom attributes.

Additional description collectiveidea/delayed_job#355

@duksis duksis commented on the diff Feb 15, 2012
@@ -8,6 +8,12 @@ module ActiveRecord
class Job < ::ActiveRecord::Base
include Delayed::Backend::Base
+ def initialize(*args)
+ # Add additionaly provided attributes to attr_accessible
+ _accessible_attributes[:default] += args[0].keys if args.size > 0 && args[0].size > 2
duksis added a note Feb 15, 2012

It could be better to take the additional values from Class DelayedJob.attr_accessible, but I don't have any ideas how to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
tadast commented May 15, 2013

This would be massively helpful.
Any chance this could be merged in? If so, can I help anyhow?

sferik commented May 18, 2013

It would be helpful to rebase from master so it can be merged automatically.

tadast commented May 22, 2013

Ok, I looked at it again. For me it seems like a backwards way of doing things. Could we, instead of listing attr_accessible, list attr_protected?
This way the library could protect the attributes that should not be mass-assignet, yet allowing users to add custom columns and mass-assign them.

I see it was committed by @bryckbost 5d09042.

Is there any downsides in using attr_protected I don't see here? If you agree with my thinking, I can make a pull request.

@albus522 albus522 closed this Sep 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.