ruby on rails - RoR on Heroku - Emails not getting confirmed after clicking confirm link -
okay, created app registration system. deployed app on heroku. can register user , confirm links go inbox. when click link, shows "something went wrong..." on heroku.
the confirm link this: appname.herokuapp.com/users/wtih-i_ti5if8ikfd6qaww/confirm_email
would appreciate if give reply!
my users controller:
def create @user = user.create(user_params) if @user.save usermailer.registration_confirmation(@user).deliver flash[:success] = "please confirm email" redirect_to root_url else flash[:error] = "something went wrong..." render 'new' end end def confirm_email user = user.find_by_confirm_token(params[:id]) if user user.email_activate flash[:success] = "welcome sample app! email has been confirmed. please sign in continue." redirect_to signin_url else flash[:error] = "sorry. user not exist" redirect_to root_url end private def user_params params.require(:user).permit(:name, :username, :email, :password, :password_confirmation, :avatar_url) end end
my users.rb
require 'digest/md5' class user < activerecord::base before_create :confirmation_token before_validation :prep_email def create_avatar_url self.avatar_url = "http://www.gravatar.com/avatar/#{digest::md5.hexdigest(self.email)}?s=50" end has_secure_password validates :name, presence: true validates :username, uniqueness: true, presence: true validates :email, uniqueness: true, presence: true, format: { with: /\a[\w.+-]+@([\w]+.)+\w+\z/ } def email_activate self.email_confirmed = true self.confirm_token = nil save!(:validate => false) end private def prep_email self.email = self.email.strip.downcase if self.email end def confirmation_token if self.confirm_token.blank? self.confirm_token = securerandom.urlsafe_base64.to_s end end
the sessions controller:
def create user = user.find_by_username(params[:username]) if user && user.authenticate(params[:password]) if user.email_confirmed session[:user_id] = user.id redirect_to root_url, notice: "logged in!" else flash.now[:error] = 'please activate account following instructions in account confirmation email received proceed' end else flash.now[:error] = "invalid user/pass" end end def destroy session.delete(:user_id) redirect_to root_url, notice: "logged out." end
the app/mailers/user_mailer.rb
class usermailer < actionmailer::base default :from => "no-reply@domain.com" def registration_confirmation(user) @user = user mail(:to => "#{user.name} <#{user.email}>", :subject => "registration confirmation") end end
also added routes file
resources :users member :confirm_email end end
also added text.erb file in app/views/user_mailer/registration_confirmation.text.erb
hi <%= @user.name %>, registering! confirm registration click url below. <%= confirm_email_user_url(@user.confirm_token) %>
smtp settings in developments.rb
# don't care if mailer can't send. config.action_mailer.raise_delivery_errors = false config.action_mailer.default_url_options = {:host => "localhost:3000"} config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { address: 'smtp.gmail.com', port: 587, domain: 'gmail.com', user_name: 'mygmail@gmail.com', password: 'mypassword', authentication: 'plain', enable_starttls_auto: true }
i tried tail heroku logs (heroku logs --tail) , monitoring logs registering. gave me 500 status error on logs.
2015-04-25t08:06:21.545018+00:00 heroku[web.1]: state changed starting 2015-04-25t08:06:22.709790+00:00 heroku[router]: at=info method=get path="/" host=keplarblog4.heroku app.com request_id=d1497cc9-02f1-4b55-8f72-a2efd95faf7a fwd="117.102.24.185" dyno=web.1 connect=0ms service=267ms status=200 bytes=2847 2015-04-25t08:06:23.174505+00:00 heroku[router]: at=info method=get path="/less.js" host=keplarblog4 .herokuapp.com request_id=1d6643da-a068-48e0-bc7f-1fc9c18af1af fwd="117.102.24.185" dyno=web.1 conne ct=0ms service=6ms status=304 bytes=133 2015-04-25t08:06:23.172282+00:00 heroku[router]: at=info method=get path="/gfx/logo.png" host=keplar blog4.herokuapp.com request_id=abd50fb2-6861-47bb-b884-6c367d35d857 fwd="117.102.24.185" dyno=web.1 connect=0ms service=8ms status=304 bytes=133 2015-04-25t08:06:23.629123+00:00 heroku[router]: at=info method=get path="/gfx/logo-nettuts.png" hos t=keplarblog4.herokuapp.com request_id=77932ef2-842e-453d-b12b-fc634394ff91 fwd="117.102.24.185" dyn o=web.1 connect=0ms service=4ms status=304 bytes=133 2015-04-25t08:06:23.701511+00:00 heroku[router]: at=info method=get path="/style.less" host=keplarbl og4.herokuapp.com request_id=d28896bf-abef-4d8c-bb79-a6a3788435aa fwd="117.102.24.185" dyno=web.1 co nnect=1ms service=3ms status=304 bytes=133 2015-04-25t08:06:23.627140+00:00 heroku[router]: at=info method=get path="/gfx/frog.jpg" host=keplar blog4.herokuapp.com request_id=6a33e5cd-c014-4e92-a60e-2d5ebeb1b866 fwd="117.102.24.185" dyno=web.1 connect=0ms service=7ms status=304 bytes=133 2015-04-25t08:06:24.014723+00:00 heroku[router]: at=info method=get path="/gfx/bg-header.png" host=k eplarblog4.herokuapp.com request_id=9ab6b848-e862-4632-820d-fb9e900f6b61 fwd="117.102.24.185" dyno=w eb.1 connect=0ms service=7ms status=304 bytes=133 2015-04-25t08:06:24.027774+00:00 heroku[router]: at=info method=get path="/gfx/bg-footer.png" host=k eplarblog4.herokuapp.com request_id=2fcb8907-9790-4c7c-84e9-e7f00f461110 fwd="117.102.24.185" dyno=w eb.1 connect=1ms service=3ms status=304 bytes=133 2015-04-25t08:06:24.007494+00:00 heroku[router]: at=info method=get path="/gfx/bg.png" host=keplarbl og4.herokuapp.com request_id=5b210759-353a-41a1-b66a-47a4f4da16d8 fwd="117.102.24.185" dyno=web.1 co nnect=1ms service=7ms status=304 bytes=133 2015-04-25t08:06:24.353070+00:00 heroku[router]: at=info method=get path="/favicon.ico" host=keplarb log4.herokuapp.com request_id=8fc598ef-7e97-4873-94f1-09505a49088b fwd="117.102.24.185" dyno=web.1 c onnect=0ms service=5ms status=304 bytes=133 2015-04-25t08:07:33.733667+00:00 heroku[router]: at=info method=post path="/users" host=keplarblog4. herokuapp.com request_id=d9d4685f-9aab-404a-874d-ebcd3f543573 fwd="117.102.24.185" dyno=web.1 connec t=0ms service=3262ms status=302 bytes=1033 2015-04-25t08:07:34.035847+00:00 heroku[router]: at=info method=get path="/" host=keplarblog4.heroku app.com request_id=d090ea4d-20e4-4ca4-a668-ecb0831e2962 fwd="117.102.24.185" dyno=web.1 connect=0ms service=18ms status=200 bytes=3049 2015-04-25t08:08:10.065104+00:00 heroku[router]: at=info method=get path="/users/5goyuwa3-rqdg8whzmj yjq/confirm_email" host=keplarblog4.herokuapp.com request_id=ee307920-1157-4037-8d89-7d6b652965be fw d="117.102.24.185" dyno=web.1 connect=0ms service=27ms status=500 bytes=1754
thanks in advance!
Comments
Post a Comment