Nicholas Barthelemy
2009-Jun-15 02:02 UTC
NoMethodError: undefined method `password_reset_instructions'' for UserNotifier:Class
Any ideas what would be causing this?
NoMethodError: undefined method `password_reset_instructions'' for
UserNotifier:Class
from /Library/Ruby/Gems/1.8/gems/actionmailer-2.3.2/lib/action_mailer/
base.rb:400:in `method_missing''
*** app/models/user_notifier.rb
class UserNotifier < ActionMailer::Base
def signup_notification(user)
setup user
subject ''Your new account''
body :url => account_url
end
def password_reset_instructions(user)
setup user
subject "Password Reset Instructions"
body :edit_password_reset_url => edit_password_reset_url
(user.perishable_token, :host => user.account.host)
end
protected
def setup(user)
from "noreply@#{ENV[''DEFAULT_DOMAIN'']}"
recipients user.email
sent_on Time.now
end
end
*** config/initializers/action_mailer_config.rb
require ''smtp_tls''
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:tls => true,
:address => "smtp.gmail.com",
:port => 587,
:domain => "<my domain>",
:authentication => :plain,
:user_name => "<my email>",
:password => "<my password>"
}
*** lib/smtp_tls.rb
require "openssl"
require "net/smtp"
# http://blog.pomozov.info/posts/how-to-send-actionmailer-mails-to-gmailcom.html
Net::SMTP.class_eval do
private
def do_start(helodomain, user, secret, authtype)
raise IOError, ''SMTP session already started'' if @started
check_auth_args user, secret, authtype if user or secret
sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
@socket = Net::InternetMessageIO.new(sock)
@socket.read_timeout = 60 #@read_timeout
check_response(critical { recv_response() })
do_helo(helodomain)
raise ''openssl library not installed'' unless
defined?(OpenSSL)
starttls
ssl = OpenSSL::SSL::SSLSocket.new(sock)
ssl.sync_close = true
ssl.connect
@socket = Net::InternetMessageIO.new(ssl)
@socket.read_timeout = 60 #@read_timeout
do_helo(helodomain)
authenticate user, secret, authtype if user
@started = true
ensure
unless @started
# authentication failed, cancel connection.
@socket.close if not @started and @socket and not
@socket.closed?
@socket = nil
end
end
def do_helo(helodomain)
begin
if @esmtp
ehlo helodomain
else
helo helodomain
end
rescue Net::ProtocolError
if @esmtp
@esmtp = false
@error_occured = false
retry
end
raise
end
end
def starttls
getok(''STARTTLS'')
end
def quit
begin
getok(''QUIT'')
rescue EOFError
rescue OpenSSL::SSL::SSLError
end
end
end
Any Help would be greatly appreciated. I get the same result in
console.
Thanks
Nicholas
Sijo Kg
2009-Jun-15 05:52 UTC
Re: NoMethodError: undefined method `password_reset_instruct
> NoMethodError: undefined method `password_reset_instructions'' for > UserNotifier:ClassHi can you post the code from where you are trying to call password_reset_instructions def? Sijo -- Posted via http://www.ruby-forum.com/.
Seemingly Similar Threads
- Errno::EBADF Send an Email in Rails using GMail
- Mailing error in Rails 2.3.2
- Mailer failure: ArgumentError: A sender (Return-Path, Sender or From) required to send a message
- Problem with ActionMailer in controller specs - works in model specs
- Introducing MailJack: autogenerate querystring parameters that are appended to links in your emails