1

my app is Rails 3 + Delayed Job (2.1.4) + Devise(2.1.2) + Devise Async (0.3.1).

I'm using this devise setup to have all the devise emails sent async. This works fine for new users but in my invite flow I do the following:

added_user = User.new(:email => email, :added_by => current_user, :added_to => @group)

The problem here is that added_by and added_to are virtual attributes (attr_accessor). And when Delayed Job Async inserts the jobs in Delayed Job the virtual attributes are not there and errors occur.

Any ideas on how to handle this situation? Is this a Delayed Job issues or Devise Async Issue? I'm not entirely sure where to start and google searches weren't helpful.

Thanks

AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012

2 Answers2

0

The only thing I can think of is that you haven't made added_by and added_to accessible via mass-assignment. In later versions of Rails, you can have it raise a MassAssignmentSecurity error, but this may not be available or enabled in your case. Try adding the following to your model:

attr_accessible :added_by, :added_to
Peter Brown
  • 50,956
  • 18
  • 113
  • 146
0

DelayedJob has significant issues with attribute accessors (so I very much doubt your problem has to do with Devise). Essentially, ActiveRecord::Base's encode_with and init_with methods need to be overridden to include attribute accessors when using DelayedJob -- at least unless you are using custom. I would suggest looking here for an idea of how to work around this issue.

Community
  • 1
  • 1
CodeBiker
  • 2,985
  • 2
  • 33
  • 36