Я успешно использую Authlogic и пытаюсь добавить возможность пользователям сбрасывать свой пароль на , используя это руководство . Когда я отправляю запрос (к действию PasswordResetsController # create) для сброса пароля, я получаю эту ошибку:
TypeError (can't convert nil into String):
app/models/user.rb:19:in `deliver_password_reset_instructions!'
app/controllers/password_resets_controller.rb:12:in `create'
Я несколько раз проходил урок, а также просматривал пример приложения здесь . Я не могу понять, что происходит. Кто-нибудь имеет какой-либо опыт / направление на эту реализацию и ошибки?
Вот полный вывод терминала:
Processing PasswordResetsController#create (for 127.0.0.1 at 2010-11-11 11:32:19) [POST]
Parameters: {"commit"=>"Reset my password", "authenticity_token"=>"G2dtgfJJktJN7iX1FWPHvG5wjLKkIXEIZvJ72+zfSIk=", "email"=>"bgadoci@gmail.com"}
User Load (0.4ms) SELECT * FROM "users" WHERE ("users"."email" = 'bgadoci@gmail.com') LIMIT 1
User Update (0.3ms) UPDATE "users" SET "updated_at" = '2010-11-11 17:32:19', "perishable_token" = 'uu_LhCF77GCNbzYfHb2v' WHERE "id" = 1
TypeError (can't convert nil into String):
app/models/user.rb:19:in `deliver_password_reset_instructions!'
app/controllers/password_resets_controller.rb:12:in `create'
Rendered rescues/_trace (129.1ms)
Rendered rescues/_request_and_response (0.3ms)
Rendering rescues/layout (internal_server_error)
User.rb
def deliver_password_reset_instructions!
reset_perishable_token!
Notifier.deliver_password_reset_instructions(self)
end
Обновление:
Я использую рельсы 2.3.8 и ruby 1.8.7
Обновление:
Notifier.rb
default_url_options[:host] = "foobar.com"
def password_reset_instructions(user)
subject "Password Reset Instructions"
from "foobar"
recipients user.email
sent_on Time.now
body :edit_password_reset_url => edit_password_reset_url(user.perishable_token)
end
Обновление:
Вот /views/notifier/password_rest_instruction.erb
A request to reset your password has been made. If you did not make this request, simply ignore this email. If you did make this request just click the link below:
<%= @edit_password_reset_url %>
If the above URL does not work try copying and pasting it into your browser. If you continue to have problem please feel free to contact us.