[delayed_job] Using attr_accessible For Mass-Assignment

272 views
Skip to first unread message

Bryce Thornton

unread,
Apr 18, 2010, 9:47:46 PM4/18/10
to delayed_job
I explicitly turn off mass-assignment in ActiveRecord via this
initializer:

ActiveRecord::Base.send(:attr_accessible, nil)

This requires that I define the allowable attributes to be mass-
assigned in any ActiveRecord object. DJ uses mass-assignment for the
following attributes :priority, :payload_object, :run_at. I've added
the following line to lib/delayed/backend/active_record.rb to get it
to work for me:

attr_accessible :priority, :payload_object, :run_at

Is there a way for me to extend the DJ ActiveRecord object so I can do
this outside of the core DJ code? Or, would it be possible to add this
to core DJ for people like me that disable mass-assignment?

Thanks,
Bryce


--
Subscription settings: http://groups.google.com/group/delayed_job/subscribe?hl=en

Brandon Keepers

unread,
Apr 19, 2010, 10:55:25 AM4/19/10
to delay...@googlegroups.com

On Apr 18, 2010, at 9:47 PM, Bryce Thornton wrote:

> I explicitly turn off mass-assignment in ActiveRecord via this
> initializer:
>
> ActiveRecord::Base.send(:attr_accessible, nil)
>
> This requires that I define the allowable attributes to be mass-
> assigned in any ActiveRecord object. DJ uses mass-assignment for the
> following attributes :priority, :payload_object, :run_at. I've added
> the following line to lib/delayed/backend/active_record.rb to get it
> to work for me:
>
> attr_accessible :priority, :payload_object, :run_at
>
> Is there a way for me to extend the DJ ActiveRecord object so I can do
> this outside of the core DJ code? Or, would it be possible to add this
> to core DJ for people like me that disable mass-assignment?
>
> Thanks,
> Bryce

You should be able to put the following in an initializer:

Delayed::Worker.backend = :active_record
Delayed::Job.attr_accessible :priority, :payload_object, :run_at

=b

Bryce Thornton

unread,
Apr 20, 2010, 8:55:43 PM4/20/10
to delayed_job
That seems to work. Thanks!
Reply all
Reply to author
Forward
0 new messages