I receive always the same error whenever I try to signup a new user in my Rails app - I use Devise for registrations, CanCanCan and Sendgrid for sending the notification mail at the new user's email.
The new user can signup, but then the error appears:
NameError in UserRegistrations#create
Showing C:/Users/Adsidera/FreshObst/app/views/user_mailer/welcome.html.erb where line #4 raised:
undefined local variable or method `user' for #<#<Class:0x5777fb8>:0x5bdac78>
Rails.root: C:/Users/Adsidera/FreshObst
Application Trace | Framework Trace | Full Trace
app/views/user_mailer/welcome.html.erb:4:in `_app_views_user_mailer_welcome_html_erb__1004447735_47859732'
app/mailers/user_mailer.rb:14:in `welcome'
app/controllers/user_registrations_controller.rb:7:in `create'
This is the user_registrations_controller.rb
class UserRegistrationsController < Devise::RegistrationsController
before_filter :configure_permitted_parameters
def create
super
if #user.persisted?
UserMailer.welcome(#user).deliver_now
end
end
protected
# my custom fields are :name, :heard_how
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) do |u|
u.permit(:first_name, :last_name,
:email, :password, :password_confirmation)
end
devise_parameter_sanitizer.for(:account_update) do |u|
u.permit(:first_name,
:email, :password, :password_confirmation, :current_password)
end
end
end
And this is the user_mailer.rb
class UserMailer < ApplicationMailer
default from: "freshobstuser#yahoo.com"
def contact_form(email, name, message)
#message = message
mail(:from => email,
:to => 'freshobstuser#yahoo.com',
:subject => 'A new contact form message from #{name}'
)
end
def welcome(user)
#appname = "FreshObst"
mail(:to => user.email,
:subject => "Welcome to #{#appname}!")
end
end
This is the link to my github as well https://github.com/Adsidera/FreshObst
Thank you! I am getting nuts over it...
Anna
UPDATE!
After the advise by Illusionist, the issue seems half-solved, now I have this log:
UserMailer#welcome: processed outbound mail in 83.0ms
Sent mail to dummy#email.com (638.0ms)
Date: Fri, 04 Mar 2016 13:38:21 +0100
From: freshobstuser#yahoo.com
To: dummy#email.com
Message-ID: <56d981bd691e4_a241d243945917a#Adsidera-PC.mail>
Subject: Welcome to FreshObst!
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
X-SMTPAPI: {"to":[ "mikecontin67#gmail.com" ]}
<html>
<body>
<table>
<tbody>
<tr>
<td><h2>Welcome Mike!</h2></td>
</tr><br>
<tr><td><p>Thank you for signing up with FreshObst</p></td>
</tr>
<tr><td><p>We wish you a fruity and healthy shopping by us ;) </p></td>
</tr>
<tr> <td><p><strong>Your FreshObst Team!</strong></p></td>
</tr><br><br>
<tr><td><p><small>This is an automated message. Please do not reply to this mail</small></p></td>
</tr>
</tbody>
</table>
</body>
</html>
Completed 500 Internal Server Error in 1048ms (ActiveRecord: 86.0ms)
Net::SMTPFatalError (550 Unauthenticated senders not allowed
):
app/controllers/user_registrations_controller.rb:7:in `create'
Rendered C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/_source.erb (2.0ms)
Rendered C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (5.0ms)
Rendered C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.0ms)
Rendered C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (75.0ms)
Rendered C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/web-console-2.2.1/lib/web_console/templates/_markup.html.erb (1.0ms)
Rendered C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/web-console-2.2.1/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (1.0ms)
Rendered C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/web-console-2.2.1/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (1.0ms)
Rendered C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/web-console-2.2.1/lib/web_console/templates/style.css.erb within layouts/inlined_string (2.0ms)
Rendered C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/web-console-2.2.1/lib/web_console/templates/console.js.erb within layouts/javascript (133.0ms)
Rendered C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/web-console-2.2.1/lib/web_console/templates/main.js.erb within layouts/javascript (1.0ms)
Rendered C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/web-console-2.2.1/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.0ms)
Rendered C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/web-console-2.2.1/lib/web_console/templates/index.html.erb (224.0ms)
SOLUTION of LAST ERROR: This last error though seemed to be caused by the yahoo.com mail address I chose per default, as from my SendGrid logs: "550 5.7.1 Unauthenticated email from yahoo.com is not accepted due to domain's DMARC policy. Please contact administrator of yahoo.com domain if this was a legitimate mail. Please visit https://support.google.com/mail/answer/2451690 to learn about DMARC initiative."
Changing then the default mailaddress to a non-yahoo mail address solved the issue.
Thank you all a lot!
try this
# in app/views/user_mailer/welcome.html.erb
<td><h2>Welcome <%= #user.first_name %>!</h2></td>
and
# in app/mailers/user_mailer.rb
def welcome(user)
#user = user
#appname = "FreshObst"
mail(:to => #user.email,
:subject => "Welcome to #{#appname}!")
end
SOLUTION TO LAST ERROR : This last error though seemed to be caused by the yahoo.com mail address I chose per default, as from my SendGrid logs: "550 5.7.1 Unauthenticated email from yahoo.com is not accepted due to domain's DMARC policy. Please contact administrator of yahoo.com domain if this was a legitimate mail. Please visit https://support.google.com/mail/answer/2451690 to learn about DMARC initiative."
Changing then the default mailaddress to a non-yahoo mail address solved the issue.
Related
I'm currently building a small website for a friend, and I want him to be able to change his password, since the one he'll get is seeded and visible from the Git repository (don't worry, he's well aware this is the first thing he'll have to change)
I'm used to Ruby on Rails in general, but this is the first time for me that I use an API instead of the "standard" version of Rails, and I'm not used at all with everything about tokens and such.
In the back-office where he can change some elements from the website, I made a specific page where he can change some details such as his biography, his profile picture, his social networks links, etc etc. On this page, I added a part where he can change his password, with the fields current_password, password and password_confirmation. I also started to setup some verifications, but the thing is that if I type 3 times "password" in the fields, I'll get the following error:
ActiveRecord::RecordInvalid | Validation failed: password can't be blank
What troubles me are two elements: the first one is that the error is not returned as JSON, but as HTML (this is my first question, how can I force the format to JSON?), and I made sure that the passwords were sent to the API (front is VueJS, but this is not the problem), but it still shows up the error.
Here is my code:
users_controller.rb
# ...
wrap_parameters :user, include: %i[password password_confirmatioon current_password]
# ...
def profile
if #user.update(user_params)
render json: #user, status: :ok
else
render json: #user.errors, status: :unprocessable_entity
end
#user.reset_password!(user_params[:new_password])
end
user.rb
class User < ApplicationRecord
mount_base64_uploader :picture, BioFaceUploader
include ActiveModel::Serializers::JSON
has_secure_password
attr_accessor :old_password
attr_accessor :profile
def generate_password_token!
begin
self.reset_password_token = SecureRandom.urlsafe_base64
end while User.exists?(reset_password_token: reset_password_token)
self.reset_password_token_expires_at = 1.day.from_now
save!
end
def reset_password!(password)
self.reset_password_token = nil
self.password = password
save!
end
def clear_password_token!
self.reset_password_token = nil
self.reset_password_token_expires_at = nil
save!
end
end
** edit: this is the server log input when I try to POST the new password**
Started POST "/profile" for 127.0.0.1 at 2018-09-21 13:15:33 +0200
Processing by UsersController#profile as HTML
Parameters: {"id"=>1, "email"=>"email#email.me", "password_digest"=>"[FILTERED]", [some more unrelated datas], "created_at"=>"2018-09-17T11:38:27.464Z", "updated_at"=>"2018-09-21T10:23:50.233Z", "reset_password_token"=>"[FILTERED]", "reset_password_token_expires_at"=>"[FILTERED]", "password"=>"[FILTERED]", "current_password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "user"=>{"password"=>"[FILTERED]", "current_password"=>"[FILTERED]"}}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
↳ app/controllers/users_controller.rb:39
Unpermitted parameters: :password, :current_password
Unpermitted parameters: :password, :current_password
(0.1ms) begin transaction
↳ app/controllers/users_controller.rb:27
(0.1ms) commit transaction
↳ app/controllers/users_controller.rb:27
Unpermitted parameters: :password, :current_password
(0.1ms) begin transaction
↳ app/models/user.rb:21
(0.1ms) rollback transaction
↳ app/models/user.rb:21
Completed 500 Internal Server Error in 32ms (Views: 0.6ms | ActiveRecord: 1.5ms)
As you can see, 2 fields were unauthorized, I added them to the allowed parameters, but now I have the following error:
Unknown attribute 'current_password' for User
Should I add it to the attr_accessor's list?
What should I do to fix this?
Thank you in advance
I've set up account activation emails. When I go to the preview page:
http://localhost:3000/rails/mailers/agent_mailer/account_activation
The view is blank. The page correctly formats the to/from addresses and the subject, but there is no body to the email.
Here are some of the server logs:
Started GET "/rails/mailers/agent_mailer/account_activation?part=text%2Fhtml" for ::1 at 2015-05-19 17:42:27 -0700
Processing by Rails::MailersController#preview as HTML
Parameters: {"part"=>"text/html", "path"=>"agent_mailer/account_activation"}
Agent Load (0.5ms) SELECT "agents".* FROM "agents" ORDER BY "agents"."id" ASC LIMIT 1
Rendered agent_mailer/account_activation.html.erb within layouts/mailer (0.1ms)
Rendered agent_mailer/account_activation.text.erb within layouts/mailer (0.0ms)
Rendered agent_mailer/account_activation.html.erb within layouts/mailer (0.1ms)
Rendered agent_mailer/account_activation.html.erb within layouts/mailer (0.0ms)
AgentMailer#account_activation: processed outbound mail in 43.5ms
Rendered text template (0.0ms)
Completed 200 OK in 49ms (Views: 1.8ms | ActiveRecord: 0.5ms)
I don't understand why it's rendering account_activation.html.erb 3 times.
I've been banging my head against a wall for 6 hours so any help would be really appreciated :)
Here are the relevant files.
app/mailers/application_mailer.rb:
class ApplicationMailer < ActionMailer::Base
default from: "admin#example.com"
layout 'mailer'
end
app/views/layouts/mailers.html.erb:
<html>
<body>
<%= yield %>
</body>
</html>
app/views/layouts/mailers.text.erb:
<%= yield %>
app/mailers/agent_mailer.rb:
class AgentMailer < ApplicationMailer
def account_activation(agent)
#agent = agent
mail from: "admin#example.com"
mail to: agent.email
mail subject: "Agent Account Activation"
end
end
app/views/agent_mailer/account_activation.html.erb:
<p>Welcome to Example! Click on the link below to activate your agent account: </p>
<%= link_to "Activate", edit_agent_account_activation_url(#agent.activation_token, email: #agent.email) %>
app/views/agent_mailer/account_activation.text.erb:
Welcome to Example! Click on the link below to activate your agent account:
<%= edit_agent_account_activation_url(#agent.activation_token, email: #agent.email) %>
I've tried putting some extra text in the layouts/mailers file but that doesn't render either. So I thought then that the layouts weren't being properly called. However, when I put layout 'something' in the application_mailer.rb I got an error for a missing layout. I commented out #agent = agent and got an nil exception at the #agent.activation_token.
So it seems like the layout and the template are being processed, but for some reason they aren't being rendered.
You can't call 'mail' so many times.
app/mailers/agent_mailers.rb:
class AgentMailer < ApplicationMailer
def account_activation(agent)
#agent = agent
mail from: "admin#example.com", to: agent.email, subject: "Agent Account Activation"
end
end
I'm trying to implement a signup form. See this screenshot. I'm using the LearnRails tutorial to help me.
It works when you type in a valid email address. However, if you don't type in a valid email address, it's giving me this error: undefined method 'empty?' for nil:NilClass. My logs say this:
ActionView::Template::Error (undefined method `name' for nil:NilClass):
1: <% content_for(:title, "#{#college.name} Student Reviews" + " | #{params[:section1]} | #{params[:section2]}".titleize) %>
2: <% description "#{#question}" %>
3:
4: <div id="college_pages_css">
app/views/college_pages/disqus_normal.html.erb:1:in `_app_views_college_pages_disqus_normal_html_erb___3963356040782610986_70269489097160'
Which is weird because it should be redirecting to my home page, which doesn't have the #college variable.
Note: I'm using the activerecord-tableless gem, because the tutorial uses it.
Model
class Subscriber < ActiveRecord::Base
attr_accessible :email
has_no_table
column :email, :string
validates_presence_of :email
validates_format_of :email,
:with => /\A[-a-z0-9_+\.]+\#([-a-z0-9]+\.)+[a-z0-9]{2,4}\z/i
def subscribe
mailchimp = Gibbon::API.new(ENV['MAILCHIMP_API_KEY'])
result = mailchimp.lists.subscribe({
:id => ENV['MAILCHIMP_LIST_ID'],
:email => {:email => self.email},
:double_optin => false,
:update_existing => true,
:send_welcome => true
})
Rails.logger.info("Subscribed #{self.email} to MailChimp") if result
end
end
Controller
class SubscriberController < ApplicationController
def create
#subscriber = Subscriber.new(params[:subscribe])
if #subscriber.valid?
#subscriber.subscribe
redirect_to root_path
else
render root_path
end
end
end
View
<%= simple_form_for :subscribe, url: 'subscribe' do |f| %>
<%= f.input :email, label: false %> <br/>
<%= f.button :submit, "Notify me", class: "btn btn-primary" %>
<% end %>
Note that the tutorial uses a secure_params method while I'm using attr_accessible. I wouldn't think that this would be a problem, but it's possible.
I was thinking of ignoring this issue, and just using client side validations, but that causes my site to crash. On the topic of client side validations, aren't HTML5 email input fields supposed to automatically validate?
How can I fix this issue?
Edit: Logs when I load the home page
Started GET "/" for 127.0.0.1 at 2014-04-01 16:15:47 -0400
Processing by StaticPagesController#home as HTML
Rendered static_pages/home.html.erb within layouts/application (3.6ms)
Completed 200 OK in 41ms (Views: 40.3ms | ActiveRecord: 0.0ms)
Started GET "/assets/jquery.ui.theme.css?body=1" for 127.0.0.1 at 2014-04-01 16:15:47 -0400
Started GET "/assets/jquery.ui.accordion.css?body=1" for 127.0.0.1 at 2014-04-01 16:15:47 -0400
.
.
.
Started GET "/favicon.ico" for 127.0.0.1 at 2014-04-01 16:15:49 -0400
Started GET "/favicon/academics/professors/1" for 127.0.0.1 at 2014-04-01 16:15:50 -0400
Processing by CollegePagesController#disqus_normal as */*
Parameters: {"college"=>"favicon", "section1"=>"academics", "section2"=>"professors", "question_id"=>"1"}
College Load (1.4ms) SELECT "colleges".* FROM "colleges" WHERE "colleges"."url" = 'favicon' LIMIT 1
Rendered college_pages/disqus_normal.html.erb within layouts/application (3.7ms)
Completed 500 Internal Server Error in 14ms
ActionView::Template::Error (undefined method `name' for nil:NilClass):
1: <% content_for(:title, "#{#college.name} Student Reviews" + " | #{params[:section1]} | #{params[:section2]}".titleize) %>
2: <% description "#{#question}" %>
3:
4: <div id="college_pages_css">
app/views/college_pages/disqus_normal.html.erb:1:in `_app_views_college_pages_disqus_normal_html_erb___3963356040782610986_70269489097160'
Rendered /Users/adamzerner/.rvm/gems/ruby-2.0.0-p451#global/gems/actionpack-4.0.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (80.6ms)
Rendered /Users/adamzerner/.rvm/gems/ruby-2.0.0-p451#global/gems/actionpack-4.0.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.6ms)
Rendered /Users/adamzerner/.rvm/gems/ruby-2.0.0-p451#global/gems/actionpack-4.0.3/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (98.3ms)
Started GET "/assets/favicon.ico" for 127.0.0.1 at 2014-04-01 16:15:50 -0400
disqus_normal action
def disqus_normal
#college = College.find_by_url(params[:college])
#question = get_question(params[:section2], params[:question_id])
end
The error
undefined method 'name' for nil:NilClass
is appearing on line 1 which is
<% content_for(:title, "#{#college.name} Student Reviews" + " | #{params[:section1]} | #{params[:section2]}".titleize) %>
of college_pages/disqus_normal.html.erb page.
It means that #college is nil and you are trying to access property name on a nil object. Hence, the error.
To resolve this make sure that you set the value of #college instance variable in the action from where you are redirecting to this page.
UPDATE
Also, there was an issue with routing.
get '/:college', to: redirect('/%{college}/academics/professors/1')
Because of the above problematic route GET "/favicon.ico" is getting converted to GET "/favicon/academics/professors/1" and disqus_normal is getting called. Ideally it would be better if you add some static text to the problematic route.
For example:
get '/college/:college', to: redirect('/%{college}/academics/professors/1')
I'm fairly new to Rails, so this will likely end up being something obvious; however I've just spent the better part of a day pulling my hair out over this issue.
I have a rails app which I've been working on for awhile, however I only started implementing mailers today. I followed the Rails ActionMailer tutorial here: http://guides.rubyonrails.org/v3.0.3/action_mailer_basics.html and the mailer works fine in a new example app. However, when I repeated those steps verbatim in my existing rails app (running in Development environment) I receive the below error. It creates the entry in the DB, correctly sends both the plain text & HTML emails and THEN generates the error. All I'm trying to do here is send a welcome email upon the creation of a new account, but I'm getting the same error when I try to send any email from any controller.
The specific error I'm seeing after it sends the welcome email is:
Completed 500 Internal Server Error in 280ms
NoMethodError (undefined method `error' for true:TrueClass):
app/controllers/musers_controller.rb:52:in `block in create'
app/controllers/musers_controller.rb:50:in `create'
Note that to not mess up my existing User table, I created a temporary scaffold & mailer called Muser which I plan on deleting once I'm confident this will work correctly on my user table.
Code
Error in log:
Started POST "/musers" for 127.0.0.1 at 2013-07-10 20:32:34 -0400
Processing by MusersController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"OuoEmsjkAVBHZwqPO5b/O4eKw6iZBaLP6vUT6f9WCOI=", "muser"=>{"name"=>"New User", "email"=>"User#email.com"}, "commit"=>"Create"}
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]]
(0.1ms) begin transaction
SQL (0.6ms) INSERT INTO "musers" ("created_at", "email", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Thu, 11 Jul 2013 00:32:34 UTC +00:00], ["email", "User#email.com"], ["name", "New User"], ["updated_at", Thu, 11 Jul 2013 00:32:34 UTC +00:00]]
(1.7ms) commit transaction
Rendered muser_mailer/registration_confirmation.html.erb (0.1ms)
Rendered muser_mailer/registration_confirmation.text.erb (0.0ms)
Completed 500 Internal Server Error in 280ms
NoMethodError (undefined method `error' for true:TrueClass):
app/controllers/musers_controller.rb:52:in `block in create'
app/controllers/musers_controller.rb:50:in `create'
Rendered /usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.6ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.5ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (15.3ms)
--I should note that lines 50 & 52 of the musers_controller (where this error is being generated) correspond to the 'respond_to do' & 'MuserMailer.... .deliver' lines in the controller code below.--
The controller action:
# POST /musers
# POST /musers.json
def create
#muser = Muser.new(params[:muser])
respond_to do |format|
if #muser.save
MuserMailer.registration_confirmation(#muser).deliver
format.html { redirect_to #muser, notice: 'Muser was successfully created.' }
format.json { render json: #muser, status: :created, location: #muser }
else
format.html { render action: "new" }
format.json { render json: #muser.errors, status: :unprocessable_entity }
end
end
end
Mailer:
class MuserMailer < ActionMailer::Base
default from: "EmailAddress#Inter.net"
def registration_confirmation(muser)
#muser = muser
mail(:to => muser.email, :subject => "Registered")
end
end
I don't think that the issue is with my smtp, mail setup, or variables since it does actually add to the DB & send the emails correctly. If I comment out the line in the controller which calls the mail action the error disappears, so I don't think the problem is with my muser routes. This undefined method 'error' for true:TrueClass is driving me nuts. I did recently install Devise on my Users table, so I don't know if that could be causing the issue?
For lack of a better term, it feels like the issue is with how Rails wants to route after sending the emails; as if I need to put a Return or specify a route at the end of my mailer action telling the server to head back to the controller action. In other words, I'm lost!
Update
Below are the two mailer view files I'm using.
registration_confirmation.html.erb
<h3><%= #muser.name %>! You sweet sweet fool!</h3>
<p>Thank you for registering!</p>
registration_confirmation.text.erb
Thank you for registering!
Update 2
Here's my model for Muser:
class Muser < ActiveRecord::Base
attr_accessible :email, :name
end
I solved this issue - there was the errant line config.action_mailer.logger = true in my config/environments/development.rb file that was causing the issues. Once removed everything worked perfectly.
I am successfully using Authlogic and I am trying to add the ability for users to reset their password by using this tutorial. When I submit the request (to the PasswordResetsController#create action) to reset the password I am getting this error:
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'
I have been through tutorial several times and also combed through the sample app of it here. I can't seem to figure out what is going on. Anyone have any experience/direction on this implementation and error?
Here is the full terminal output:
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
Update:
I'm using rails 2.3.8 and ruby 1.8.7
Update:
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
Update:
Here is the /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.
The output is telling you there's an error in line 19 of User#deliver_password_reset_instructions! Paste your code and I'll be able to help you more...