lundi 30 mars 2015

Full URL is not coming when using action mailer in Rail 3?

I am trying to implement reset password feature in my app using Ruby on Rails.I am using action mailer to send link to user's email.The email is delivering to user with link but when user is clicking on that link the full URL is not coming(i.e-"localhost:3000/homes/resetpass").Only "/homes/resetpass" is coming.Please check my following codes and help me to resolve this issue.


views/user_mailer/registration_confirmation.html.erb



<p><%= @users.first_name %>,</p>

<p>Thank you for registering!</p>

<p>Edit Your Password <%= link_to "Click Here",homes_resetpass_path(:id => @users.id ),:host => "localhost:3000" %></p>


mailers/user_mailers.rb



class UserMailer < ActionMailer::Base
default from: "rajatpradhan474@gmail.com"
def registration_confirmation(user)
@users = user
mail(:to => user.email, :subject => "Registered")
end
end


config/initializers/setup_mail.rb



ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "rajatpradhan474@gmail.com",
:password => "**********",
:authentication => "plain",
:enable_starttls_auto => true
}
ActionMailer::Base.default_url_options[:host] = "localhost:3000"

Aucun commentaire:

Enregistrer un commentaire