Rails 4.2 Active Job Resque Enqueue No Route Matches

Я подписан на https://blog.engineyard.com/2014/getting-started-with-active-job для реализации Active Job в Rails 4.2. Но столкнулся со следующей проблемой в Resque. Ошибка гласит:

ChickenSmitten.local:67478 on MAILERS at just now Retry or Remove
ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper
---
job_class: ActionMailer::DeliveryJob
job_id: 36cc80d1-109d-4238-990e-2df43205e91d
queue_name: mailers
arguments:
- UserMailer
- password_reset
- deliver_now
- _aj_globalid: gid://affiliation/User/1
- ActionView::Template::Error
- No route matches {:action=>"edit", :controller=>"password_resets", :email=>"[email protected]", :format=>nil, :id=>nil} missing required keys: [:id]

Мои коды ниже:

password_resets_controller.rb

  def create
    @user = User.find_by(email: params[:password_reset][:email].downcase)
    if @user
      @user.create_reset_digest
      @user.send_password_reset_email
      flash[:notice] = "Email sent with password reset instructions"
      redirect_to root_url
    else
      flash.now[:error] = "Email address not found"
      render 'new'
    end
  end

пользователь.rb

  def send_password_reset_email
    PasswordResetJob.new(self).enqueue(wait: 10.seconds)
  end  

приложение/работы/password_reset_job.rb

class PasswordResetJob < ActiveJob::Base
  queue_as :email

  def perform(email)
    UserMailer.password_reset(email).deliver_later
  end
end

приложение/почтовые программы/user_mailer.rb

class UserMailer < ActionMailer::Base
  default from: "[email protected]"

  def password_reset(user)
    @user = user
    mail to: user.email, subject: "Password Reset"
  end

end

Ниже приведены более подробные сведения, которые могут помочь.

[2] pry(#<User>)> PasswordResetJob.new(self).enqueue(wait: 10.seconds)
[ActiveJob] Enqueued PasswordResetJob (Job ID: 6bdcca3c-367d-48ea-b3c9-1f5378e5df57) to Resque(email) at 2015-01-06 04:58:28 UTC with arguments: gid://affiliation/User/1
=> #<PasswordResetJob:0x007fbd4c028dc8
 @arguments=
  [#<User:0x007fbd4b686590
    id: 1,
    username: "bob",
    email: "[email protected]",
    password_digest: "$2a$10$dbbEBwNgBtaZEvtl7EsUm./hdukr3MMKlUWdouV3RwIFMmMPfR6CS",
    created_at: Thu, 01 Jan 2015 03:38:54 UTC +00:00,
    updated_at: Tue, 06 Jan 2015 04:58:01 UTC +00:00,
    role: "admin",
    slug: "bob",
    activation_digest: "$2a$10$wdoO7vn5Ng4U4TEPCmqVFeVYAB8sZ2CKEpVFfduYyD7Ee.NfvSRsi",
    activated: true,
    activated_at: Thu, 01 Jan 2015 03:41:19 UTC +00:00,
    remember_digest: nil,
    reset_digest: "$2a$10$Eu1jYllohAY2IQO4Uc.0TuyNmRWWuu3jQgjZrIZLwFlo1t8n1hNZO",
    reset_sent_at: Tue, 06 Jan 2015 04:58:01 UTC +00:00,
    url: "www.google.com",
    bio: "Woo ga shaka.">],
 @job_id="6bdcca3c-367d-48ea-b3c9-1f5378e5df57",
 @queue_name="email",
 @scheduled_at=1420520308.6658938>

просмотры/user_mailer/password_reset.html.rb

<h1>Password reset</h1>

<p>To reset your password click the link below:</p>

<%= link_to "Reset password", edit_password_reset_url(@user.reset_token,
                                                      email: @user.email) %>

<p>This link will expire in two hours.</p>

<p>
If you did not request your password to be reset, please ignore this email and
your password will stay as it is.
</p>

Заранее спасибо.


person chickensmitten    schedule 06.01.2015    source источник


Ответы (1)


Ответ находится здесь. Почтовая программа не может получить доступ к reset_token в пользовательской модели

Эта ссылка покажет более правильный диагноз проблемы.

person chickensmitten    schedule 13.01.2015
comment
Спасибо, что добавили это в качестве ответа. Иногда, выбирая, является ли что-то дубликатом или нет, может потребоваться много чтения, чтобы понять вопросы, чтобы я понял это правильно. Если вы подтвердите это, нам будет легче поддерживать порядок в этом месте. - person Wayne Conrad; 06.07.2016