-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RecordNotFound error when using ActionMailer's deliver_later method #36
Comments
I've tracked down the problem. It lies in your reimplementation of the ActionMailer's
Now well, what to do about this? I'm stumped. |
I ran into this, and I used |
@cobalamin I am having a similar issue but my process is the opposite as yours. I am using Resque to queue my background thumbnail worker - which then re-saves the object. It doesn't seem to matter whether I find the object via the obfuscated ID or using the actual object ID - the results are the same. Simple background queue variation (plain id vs. obfuscated):
-or-
The worker:
Note: when using the second worker The results:
|
On closer inspection, it seems that maybe it's an issue with carriewave's 'store_previous_model_for_file' method. |
@swaathi I think it would help, but I can't change core Rails libraries... I worked around this by transmitting the "real" ID to the mailing methods: FlawMailer.user_email(@flaw.id) and then having the mailing methods find the model themselves, through that passed ID. It's certainly just a workaround because it requires the mailing methods to fetch the model, increasing coupling, but at least it works. |
Hey @cobalamin You can always try to retrieve the original ID from the scattered ID. You can see it here, https://github.com/namick/obfuscate_id/blob/master/lib/obfuscate_id.rb#L11. So, Obfuscate_id uses Scatter Swap to randomize the ID's. You can always retrieve the original ID or get the random ID using the Scatter Swap functions. This requires two things, one is the ID and the other is the "spin". You can calculate the spin using this function, https://github.com/namick/obfuscate_id/blob/master/lib/obfuscate_id.rb#L44. The spin is actually calculated from your model name. So just assign the variable name to your model (say, Comment, with the capital C!), and you can generate your spin. Hope this helps! |
You can customize the locator with globalid.
|
"used |
👍 to @chengguangnan's solution. That got |
I'm using ActionMailer to deliver mails on model creation. My controller code looks like this:
I'm using
deliver_later
as I don't want the HTTP response by mailing concerns. However, this doesn't work and throws an error, apparently it's trying to use the obfuscated id to look up the Flaw model (even though I'm passing it as a parameter:When I use
deliver_now
instead, this problem vanishes. So there seems to be some incompatibilities between this gem and ActionMailer's deliver_later method.The text was updated successfully, but these errors were encountered: