前提・実現したいこと
サイトにアカウントを登録後、有効化のメールを送信してそのユーザーのプロフィール画面へ遷移するという動作を
本番環境でも実現させたいです。
開発環境では、アカウント登録後development.logに表示されるURLを開くと正常にアカウントの有効化及びプロフィール画面への遷移ができているため、ビューファイルに誤りがあるわけではなくルーティングの指定が足りていないのかな、と考えております。
開発環境と本番環境の違いが発生しているのは、有効化メールを送信した後メール内のリンクを押すと
以下のメッセージが表示される点です。
発生している問題・エラーメッセージ
The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved.
該当のソースコード
(routes.rb) Rails.application.routes.draw do root 'static_pages#home' get '/help', to: 'static_pages#help' get '/about', to: 'static_pages#about' get '/contact', to: 'static_pages#contact' get '/signup', to: 'users#new' get '/login', to: 'sessions#new' post '/login', to: 'sessions#create' delete '/logout', to: 'sessions#destroy' resources :users do member do get :following, :followers end end resources :users resources :account_activations, only: [:edit] resources :password_resets, only: [:new, :create, :edit, :update] resources :microposts, only: [:create, :destroy] resources :relationships, only: [:create, :destroy] end
(account_activation.html.erb) <h1>Sample App</h1> <p>Hi <%= @user.name %>,</p> <p> Welcome to the Sample App! Click on the link below to activate your account: </p> <%= link_to "Activate", edit_account_activation_url(@user.activation_token, email: @user.email) %>
(account_activation.text.erb) Hi <%= @user.name %> Welcome to the Sample App! Click on the link below to activate your account: <%= edit_account_activation_url(@user.activation_token, email: @user.email) %>
(account_activations_controller.rb) class AccountActivationsController < ApplicationController def edit user = User.find_by(email: params[:email]) if user && !user.activated? && user.authenticated?(:activation, params[:id]) user.activate log_in user flash[:success] = "Account activated!" redirect_to user else flash[:danger] = "Invalid activation link" redirect_to root_url end end end
試したこと
①production.rb
のhostを正しく指定できていなかったため、'<https://SAMPLEAPP.herokuapp.com/>.herokuapp.com'
へ修正しました。
②stack overflowにて同様のエラー発生原因がJavaScriptの読み込みがうまくいっていなかった旨の投稿があり、
public/assets
ディレクトリの有無を確認しましたがありませんでした。
お手数ですがよろしくお願いします。
補足情報(FW/ツールのバージョンなど)
macOS Catalina 10.15.2
ruby 2.6.3
rails 6.0.1
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/01/23 15:35