kodamarisa / osinotameni_yasetai

0 stars 0 forks source link

ルーティングエラーの解決 #25

Closed kodamarisa closed 6 months ago

kodamarisa commented 6 months ago

app/views/registrations/choose_method.html.erb:3 app/controllers/registrations_controller.rb:3:in `new' Started GET "/calendars/1" for ::1 at 2024-05-20 03:33:00 +0900 Processing by CalendarsController#show as HTML

- どの処理までうまく動いているのか
サイドバーは問題なく表示されている。
クリックして選択画面へ飛ぼうとしたら、上記のエラーで進めれない。
- 該当のソースコード
routes.rb

Rails.application.routes.draw do

Devise routes

devise_for :users, controllers: { registrations: 'registrations' }

Custom session routes

resources :sessions, only: [] do collection do get :new, path: '/login' post :create, path: '/login' get :destroy, path: '/logout' get :login_with_line, as: :line_login end end

Calendar routes

resources :calendars, only: [:index, :show, :new, :create, :edit]

Schedule routes

resources :schedules, only: [:new, :create, :edit, :update, :destroy]

Exercise routes

resources :exercises, only: [:index, :show] do collection do get :autocomplete end end

Registrations routes

resources :registrations, only: [:new] do collection do get :line_registration, path: '/line_registration' get :email_registration, path: '/email_registration' end end

Choose registration method route

get 'choose_method', to: 'registrations#new', as: :choose_registration_method

For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html

end

RegistrationsController

class RegistrationsController < ApplicationController def new render 'choose_method' end

def line_registration render 'line_users/new' end

def email_registration render 'users/new' end end

app/views/registrations/choose_method.html.erb

Choose Registration Method

<%= link_to 'Register with LINE', line_registration_path %> <%= link_to 'Register with Email', email_registration_path %>


- エラーから考えられる原因
パスがうまくいってないとのことだが、特に思い当たらない
- 試したこと
ルーティングの見直し、パスの見直し、コントローラーの見直し、
一応、スペルミス等がないかもChatGPTと自分で確認してみました。
tmtkzk0823 commented 6 months ago

上記お聞きしたいです!

kodamarisa commented 6 months ago

ユーザー登録の方法の選択画面のコントローラーはRegistrationsControllerであり、 それぞれのrenderされた画面へ移動できるようにしました。 newアクションはapp/views/registrations/choose_method.html.erbへ

<h1>Choose Registration Method</h1>

<%= link_to 'Register with LINE', line_registration_path %>
<%= link_to 'Register with Email', email_registration_path %>

line_registrationアクションはapp/views/line_users/new.html.erbへ

<h1>Register with LINE</h1>

<%= form_with model: @line_user, local: true do |form| %>
  <% if @line_user.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@line_user.errors.count, "error") %> prohibited this user from being saved:</h2>
      <ul>
        <% @line_user.errors.full_messages.each do |message| %>
          <li><%= message %></li>
        <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= form.label :name, 'Display Name' %>
    <%= form.text_field :name %>
  </div>

  <div class="field">
    <%= form.label :line_user_id, 'LINE User ID' %>
    <%= form.text_field :line_user_id %>
  </div>

  <div class="field">
    <%= form.label :profile_image_url, 'Profile Image URL' %>
    <%= form.text_field :profile_image_url %>
  </div>

  <div class="actions">
    <%= form.submit %>
  </div>
<% end %>

email_registrationはapp/views/users/new.htmlへ

<h1>Register</h1>

<%= form_with model: @user, local: true do |form| %>
  <% if @user.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
      <ul>
        <% @user.errors.full_messages.each do |message| %>
          <li><%= message %></li>
        <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= form.label :name, 'Name' %>
    <%= form.text_field :name %>
  </div>

  <div class="field">
    <%= form.label :email, 'Email' %>
    <%= form.email_field :email %>
  </div>

  <div class="field">
    <%= form.label :password, 'Password' %>
    <%= form.password_field :password %>
  </div>

  <div class="field">
    <%= form.label :password_confirmation, 'Confirm Password' %>
    <%= form.password_field :password_confirmation %>
  </div>

  <div class="actions">
    <%= form.submit %>
  </div>
<% end %>

これらのビューに飛ぶようにしたいと思ってコントローラーにrenderを使用しました。

kodamarisa commented 6 months ago

コードを見直しを行い、現在、このような形になっています。 LINE Messaging APIを用いたユーザー登録機能に関するもの

class SessionsController < ApplicationController
  def create
    auth = request.env["omniauth.auth"]
    user = LineUser.find_or_create_by(line_user_id: auth['uid']) do |u|
      u.name = auth['info']['name']
      u.profile_image_url = auth['info']['image']
      u.access_token = auth['credentials']['token']
      u.refresh_token = auth['credentials']['refresh_token']
    end

    if user.save
      session[:line_user_id] = user.id
      redirect_to calendars_path, notice: 'Successfully logged in with LINE!'
    else
      redirect_to root_path, alert: 'Failed to login with LINE.'
    end
  end

  def destroy
    session[:line_user_id] = nil
    redirect_to root_path, notice: 'Logged out successfully.'
  end
end

LineUsersController

class LineUsersController < ApplicationController
  skip_before_action :verify_authenticity_token, only: :line_callback

  def new
    @line_user = LineUser.new
  end

  def create
    @line_user = LineUser.new(line_user_params)
    if @line_user.save
      redirect_to line_user_path(@line_user), notice: 'Line User was successfully created.'
    else
      render :new
    end
  end

  def show
    @line_user = LineUser.find(params[:id])
  end

  def line_callback
    body = request.body.read
    signature = request.env['HTTP_X_LINE_SIGNATURE']

    unless LINE_CLIENT.validate_signature(body, signature)
      head :bad_request
      return
    end

    events = LINE_CLIENT.parse_events_from(body)

    events.each do |event|
      case event
      when Line::Bot::Event::Message
        case event.type
        when Line::Bot::Event::MessageType::Text
          line_user_id = event['source']['userId']
          profile = LINE_CLIENT.get_profile(line_user_id)
          user_data = JSON.parse(profile.body)

          line_user = LineUser.find_or_initialize_by(line_user_id: line_user_id)
          line_user.name = user_data['displayName']
          line_user.profile_image_url = user_data['pictureUrl']
          line_user.save!

          message = {
            type: 'text',
            text: "You have been successfully registered, #{line_user.name}!"
          }
          LINE_CLIENT.reply_message(event['replyToken'], message)
        end
      end
    end

    head :ok
  end

  def line_registration
    @line_user = LineUser.new
    render 'line_users/new'
  end

  private

  def line_user_params
    params.require(:line_user).permit(:name, :line_user_id, :profile_image_url)
  end
end

app/models/line_user.rb

class LineUser < ApplicationRecord
  has_many :calendars, dependent: :destroy
  has_many :bookmarks, dependent: :destroy

  validates :line_user_id, presence: true, uniqueness: true
  validates :name, presence: true
end

app/views/line_users/new.html.erb

<h1>Register with LINE</h1>

<%= form_with model: @line_user, local: true do |form| %>
  <% if @line_user.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@line_user.errors.count, "error") %> prohibited this user from being saved:</h2>
      <ul>
        <% @line_user.errors.full_messages.each do |message| %>
          <li><%= message %></li>
        <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= form.label :name, 'Display Name' %>
    <%= form.text_field :name %>
  </div>

  <div class="field">
    <%= form.label :line_user_id, 'LINE User ID' %>
    <%= form.text_field :line_user_id %>
  </div>

  <div class="field">
    <%= form.label :profile_image_url, 'Profile Image URL' %>
    <%= form.text_field :profile_image_url %>
  </div>

  <div class="actions">
    <%= form.submit %>
  </div>
<% end %>

deviseでのユーザー登録機能に関するものは app/models/user.rb

class User < ApplicationRecord
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :validatable

  has_many :calendars, dependent: :destroy
  has_many :bookmarks, dependent: :destroy

  validates :name, presence: true
  validates :email, presence: true, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
  validates :password, presence: true, length: { minimum: 6 }, confirmation: true
end

コントローラーはdeviseで生成されたものを使用しビューは生成された app/views/devise/registrations/new.html.erb

<h2>Sign up</h2>

<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
  <%= render "devise/shared/error_messages", resource: resource %>

  <div class="field">
    <%= f.label :email %><br />
    <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
  </div>

  <div class="field">
    <%= f.label :password %>
    <% if @minimum_password_length %>
    <em>(<%= @minimum_password_length %> characters minimum)</em>
    <% end %><br />
    <%= f.password_field :password, autocomplete: "new-password" %>
  </div>

  <div class="field">
    <%= f.label :password_confirmation %><br />
    <%= f.password_field :password_confirmation, autocomplete: "new-password" %>
  </div>

  <div class="actions">
    <%= f.submit "Sign up" %>
  </div>
<% end %>

<%= render "devise/shared/links" %>

これを使うようにし、書くユーザー登録方法のチョイス画面として app/views/registrations/choose_method.html.erb

<h1>Choose Registration Method</h1>

<%= link_to 'Register with LINE', line_registration_path %>
<%= link_to 'Register with Email', email_registration_path %>

これとし、これのコントローラーが RegistrationsController

class RegistrationsController < ApplicationController
  def new
    render 'choose_method'
  end

  def line_registration
    render 'line_users/new'
  end

  def email_registration
    redirect_to new_user_registration_path
  end
end

こうなるようにしました。 ルーティングは

Rails.application.routes.draw do
  # Devise routes
  devise_for :users, controllers: { registrations: 'registrations' }

  # Custom session routes
  resources :sessions, only: [] do
    collection do
      get :new, path: '/login'
      post :create, path: '/login'
      get :destroy, path: '/logout'
      get :login_with_line, as: :line_login
    end
  end

  # Calendar routes
  resources :calendars, only: [:index, :show, :new, :create, :edit]

  # Schedule routes
  resources :schedules, only: [:new, :create, :edit, :update, :destroy]

  # Exercise routes
  resources :exercises, only: [:index, :show] do
    collection do
      get :autocomplete
    end
  end

  # Registrations routes
  resources :registrations, only: [:new] do
    collection do
      get :line_registration, path: '/line_registration'
      get :email_registration, path: '/email_registration'
    end
  end

  # Choose registration method route
  get 'choose_method', to: 'registrations#new', as: :choose_registration_method

  # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end

となっています。 上記の状態にしても

ActionView::Template::Error (undefined local variable or method `line_registration_path' for #<ActionView::Base:0x0000000000a910>
Did you mean?  cancel_registration_path
               new_registration_path):
    1: <h1>Choose Registration Method</h1>
    2: 
    3: <%= link_to 'Register with LINE', line_registration_path %>
    4: <%= link_to 'Register with Email', email_registration_path %>

app/views/registrations/choose_method.html.erb:3
app/controllers/registrations_controller.rb:3:in `new'
Started GET "/calendars/1" for ::1 at 2024-05-20 03:33:00 +0900
Processing by CalendarsController#show as HTML

このエラーとなっています。

tmtkzk0823 commented 6 months ago

newアクションはapp/views/registrations/choose_method.html.erbへ

Railsは、特に指定がなければ、アクション名と同じ名前のついたviewファイルをレンダリングしてくれます。 ですので、renderでcontrollerのアクション名を違う名前がついたファイルを表示するのではなく、まず表示したいviewファイルの命名をアクション名を揃えるのがいいかと思うのですがいかがでしょうか?

kodamarisa commented 6 months ago

app/views/registrations/choose_method.html.erbこれを app/views/registrations/new.html.erbへと変更。それに伴い以下のように変更しました。 routes.rb

Rails.application.routes.draw do
  # Devise routes
  devise_for :users, controllers: { registrations: 'registrations' }

  # Custom session routes
  resources :sessions, only: [] do
    collection do
      get :new, path: '/login'
      post :create, path: '/login'
      get :destroy, path: '/logout'
      get :login_with_line, as: :line_login
    end
  end

  # Calendar routes
  resources :calendars, only: [:index, :show, :new, :create, :edit]

  # Schedule routes
  resources :schedules, only: [:new, :create, :edit, :update, :destroy]

  # Exercise routes
  resources :exercises, only: [:index, :show] do
    collection do
      get :autocomplete
    end
  end

  # Registrations routes
  resources :registrations, only: [:new] do
    collection do
      get :line_registration, path: '/line_registration'
      get :email_registration, path: '/email_registration'
    end
  end
  # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end

RegistrationsController

class RegistrationsController < ApplicationController
  def new
    render 'new'
  end

  def line_registration
    render 'line_users/new'
  end

  def email_registration
    redirect_to new_user_registration_path
  end
end

サイドバー

<div class="sidebar">
  <ul>
    <li><a href="/calendars">Calendars</a></li>
    <li><a href="/exercises">Exercises</a></li>
    <li><%= link_to 'Register', new_registration_path %></li>
    <li><a href="/terms_of_service">Terms of Service</a></li>
  </ul>
</div>

ですが、エラーは同じ文が出現している状態です。

tmtkzk0823 commented 6 months ago

ありがとうございます。

 def new
    render 'new'
  end

上記のrender 'new'を消して、dockerを使用している場合、コンテナの再起動をしてみていただいてもいいでしょうか?

kodamarisa commented 6 months ago

dockerではなくherokuを使用しています。 Gemfile

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.1.4'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem 'rails', '~> 6.1.7', '>= 6.1.7.4'
# Use postgresql as the database for Active Record
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 5.0'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 5.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.4', require: false

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'sqlite3', '~> 1.4'
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 4.1.0'
  # Display performance information such as SQL time and flame graphs for each request in your browser.
  # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
  gem 'rack-mini-profiler', '~> 2.0'
  gem 'listen', '~> 3.3'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 3.26'
  gem 'selenium-webdriver', '>= 4.0.0.rc1'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
end

group :production do
  gem 'pg'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem "simple_calendar"
gem 'ransack'
gem 'line-bot-api'

gem 'omniauth'
gem 'omniauth-line'
gem 'devise'

この場合はどうすればいいですか?

tmtkzk0823 commented 6 months ago

dockerではなくherokuを使用しています。

ローカル環境で動くことは確認できていますか? dockerを使用していなければ、サーバーを立ち上げ直し、エラーが出るか確認をお願いしま。

kodamarisa commented 6 months ago

ローカル環境での動作確認時に

ActionView::Template::Error (undefined local variable or method `line_registration_path' for #<ActionView::Base:0x0000000000a910>
Did you mean?  cancel_registration_path
               new_registration_path):
    1: <h1>Choose Registration Method</h1>
    2: 
    3: <%= link_to 'Register with LINE', line_registration_path %>
    4: <%= link_to 'Register with Email', email_registration_path %>

app/views/registrations/choose_method.html.erb:3
app/controllers/registrations_controller.rb:3:in `new'
Started GET "/calendars/1" for ::1 at 2024-05-20 03:33:00 +0900
Processing by CalendarsController#show as HTML

このエラーが出ています。 なお、何度かrails sにて立ち上げ直しは行なっています。

tmtkzk0823 commented 6 months ago

ありがとうございます。 rails_routesを確認指定いただき , line_registration_path が存在するか確認していただいていいですか?

kodamarisa commented 6 months ago
kodamarisa@kodamarisanoMacBook-Pro osinotameni_yasetai % rails routes
                                  Prefix Verb   URI Pattern                                                                                       Controller#Action
                        new_user_session GET    /users/sign_in(.:format)                                                                          devise/sessions#new
                            user_session POST   /users/sign_in(.:format)                                                                          devise/sessions#create
                    destroy_user_session DELETE /users/sign_out(.:format)                                                                         devise/sessions#destroy
                       new_user_password GET    /users/password/new(.:format)                                                                     devise/passwords#new
                      edit_user_password GET    /users/password/edit(.:format)                                                                    devise/passwords#edit
                           user_password PATCH  /users/password(.:format)                                                                         devise/passwords#update
                                         PUT    /users/password(.:format)                                                                         devise/passwords#update
                                         POST   /users/password(.:format)                                                                         devise/passwords#create
                cancel_user_registration GET    /users/cancel(.:format)                                                                           registrations#cancel
                   new_user_registration GET    /users/sign_up(.:format)                                                                          registrations#new
                  edit_user_registration GET    /users/edit(.:format)                                                                             registrations#edit
                       user_registration PATCH  /users(.:format)                                                                                  registrations#update
                                         PUT    /users(.:format)                                                                                  registrations#update
                                         DELETE /users(.:format)                                                                                  registrations#destroy
                                         POST   /users(.:format)                                                                                  registrations#create
                                sessions GET    /sessions/login(.:format)                                                                         sessions#new
                                         POST   /sessions/login(.:format)                                                                         sessions#create
                                         GET    /sessions/logout(.:format)                                                                        sessions#destroy
                     line_login_sessions GET    /sessions/login_with_line(.:format)                                                               sessions#login_with_line
                               calendars GET    /calendars(.:format)                                                                              calendars#index
                                         POST   /calendars(.:format)                                                                              calendars#create
                            new_calendar GET    /calendars/new(.:format)                                                                          calendars#new
                           edit_calendar GET    /calendars/:id/edit(.:format)                                                                     calendars#edit
                                calendar GET    /calendars/:id(.:format)                                                                          calendars#show
                               schedules POST   /schedules(.:format)                                                                              schedules#create
                            new_schedule GET    /schedules/new(.:format)                                                                          schedules#new
                           edit_schedule GET    /schedules/:id/edit(.:format)                                                                     schedules#edit
                                schedule PATCH  /schedules/:id(.:format)                                                                          schedules#update
                                         PUT    /schedules/:id(.:format)                                                                          schedules#update
                                         DELETE /schedules/:id(.:format)                                                                          schedules#destroy
                  autocomplete_exercises GET    /exercises/autocomplete(.:format)                                                                 exercises#autocomplete
                               exercises GET    /exercises(.:format)                                                                              exercises#index
                                exercise GET    /exercises/:id(.:format)                                                                          exercises#show
         line_registration_registrations GET    /registrations/line_registration(.:format)                                                        registrations#line_registration
        email_registration_registrations GET    /registrations/email_registration(.:format)                                                       registrations#email_registration
                        new_registration GET    /registrations/new(.:format)                                                                      registrations#new
           rails_postmark_inbound_emails POST   /rails/action_mailbox/postmark/inbound_emails(.:format)                                           action_mailbox/ingresses/postmark/inbound_emails#create
              rails_relay_inbound_emails POST   /rails/action_mailbox/relay/inbound_emails(.:format)                                              action_mailbox/ingresses/relay/inbound_emails#create
           rails_sendgrid_inbound_emails POST   /rails/action_mailbox/sendgrid/inbound_emails(.:format)                                           action_mailbox/ingresses/sendgrid/inbound_emails#create
     rails_mandrill_inbound_health_check GET    /rails/action_mailbox/mandrill/inbound_emails(.:format)                                           action_mailbox/ingresses/mandrill/inbound_emails#health_check
           rails_mandrill_inbound_emails POST   /rails/action_mailbox/mandrill/inbound_emails(.:format)                                           action_mailbox/ingresses/mandrill/inbound_emails#create
            rails_mailgun_inbound_emails POST   /rails/action_mailbox/mailgun/inbound_emails/mime(.:format)                                       action_mailbox/ingresses/mailgun/inbound_emails#create
          rails_conductor_inbound_emails GET    /rails/conductor/action_mailbox/inbound_emails(.:format)                                          rails/conductor/action_mailbox/inbound_emails#index
                                         POST   /rails/conductor/action_mailbox/inbound_emails(.:format)                                          rails/conductor/action_mailbox/inbound_emails#create
       new_rails_conductor_inbound_email GET    /rails/conductor/action_mailbox/inbound_emails/new(.:format)                                      rails/conductor/action_mailbox/inbound_emails#new
      edit_rails_conductor_inbound_email GET    /rails/conductor/action_mailbox/inbound_emails/:id/edit(.:format)                                 rails/conductor/action_mailbox/inbound_emails#edit
           rails_conductor_inbound_email GET    /rails/conductor/action_mailbox/inbound_emails/:id(.:format)                                      rails/conductor/action_mailbox/inbound_emails#show
                                         PATCH  /rails/conductor/action_mailbox/inbound_emails/:id(.:format)                                      rails/conductor/action_mailbox/inbound_emails#update
                                         PUT    /rails/conductor/action_mailbox/inbound_emails/:id(.:format)                                      rails/conductor/action_mailbox/inbound_emails#update
                                         DELETE /rails/conductor/action_mailbox/inbound_emails/:id(.:format)                                      rails/conductor/action_mailbox/inbound_emails#destroy
new_rails_conductor_inbound_email_source GET    /rails/conductor/action_mailbox/inbound_emails/sources/new(.:format)                              rails/conductor/action_mailbox/inbound_emails/sources#new
   rails_conductor_inbound_email_sources POST   /rails/conductor/action_mailbox/inbound_emails/sources(.:format)                                  rails/conductor/action_mailbox/inbound_emails/sources#create
   rails_conductor_inbound_email_reroute POST   /rails/conductor/action_mailbox/:inbound_email_id/reroute(.:format)                               rails/conductor/action_mailbox/reroutes#create
                      rails_service_blob GET    /rails/active_storage/blobs/redirect/:signed_id/*filename(.:format)                               active_storage/blobs/redirect#show
                rails_service_blob_proxy GET    /rails/active_storage/blobs/proxy/:signed_id/*filename(.:format)                                  active_storage/blobs/proxy#show
                                         GET    /rails/active_storage/blobs/:signed_id/*filename(.:format)                                        active_storage/blobs/redirect#show
               rails_blob_representation GET    /rails/active_storage/representations/redirect/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations/redirect#show
         rails_blob_representation_proxy GET    /rails/active_storage/representations/proxy/:signed_blob_id/:variation_key/*filename(.:format)    active_storage/representations/proxy#show
                                         GET    /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format)          active_storage/representations/redirect#show
                      rails_disk_service GET    /rails/active_storage/disk/:encoded_key/*filename(.:format)                                       active_storage/disk#show
               update_rails_disk_service PUT    /rails/active_storage/disk/:encoded_token(.:format)                                               active_storage/disk#update
                    rails_direct_uploads POST   /rails/active_storage/direct_uploads(.:format)                                                    active_storage/direct_uploads#create

こんな感じになりました、一応、存在してそうです。

tmtkzk0823 commented 6 months ago

こんな感じになりました、一応、存在してそうです。

確認したところ、line_registration_path存在していないように見えます。

line_registration_registrations_pathは存在しているように見えるのですが、こちらのpathでありませんか?

kodamarisa commented 6 months ago

line_registration_pathに見間違えていました。 line_registration_registrations_pathをline_registration_pathになるように下記のようにroutes.rbを書き換えました。

Rails.application.routes.draw do
  # Devise routes
  devise_for :users, controllers: { registrations: 'registrations' }

  # Custom session routes
  resources :sessions, only: [] do
    collection do
      get :new, path: '/login'
      post :create, path: '/login'
      get :destroy, path: '/logout'
      get :login_with_line, as: :line_login
    end
  end

  # Calendar routes
  resources :calendars, only: [:index, :show, :new, :create, :edit]

  # Schedule routes
  resources :schedules, only: [:new, :create, :edit, :update, :destroy]

  # Exercise routes
  resources :exercises, only: [:index, :show] do
    collection do
      get :autocomplete
    end
  end

  # Registrations routes
  resources :exercises, only: [:index, :show] do
    collection do
      get :autocomplete
    end
  end

  # Registration routes
  resources :registrations, only: [:new]
  get '/line_registration', to: 'registrations#line_registration', as: :line_registration
  get '/email_registration', to: 'registrations#email_registration', as: :email_registration

  # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end

rails routesを行うと

kodamarisa@kodamarisanoMacBook-Pro osinotameni_yasetai % rails routes
                                  Prefix Verb   URI Pattern                                                                                       Controller#Action
                        new_user_session GET    /users/sign_in(.:format)                                                                          devise/sessions#new
                            user_session POST   /users/sign_in(.:format)                                                                          devise/sessions#create
                    destroy_user_session DELETE /users/sign_out(.:format)                                                                         devise/sessions#destroy
                       new_user_password GET    /users/password/new(.:format)                                                                     devise/passwords#new
                      edit_user_password GET    /users/password/edit(.:format)                                                                    devise/passwords#edit
                           user_password PATCH  /users/password(.:format)                                                                         devise/passwords#update
                                         PUT    /users/password(.:format)                                                                         devise/passwords#update
                                         POST   /users/password(.:format)                                                                         devise/passwords#create
                cancel_user_registration GET    /users/cancel(.:format)                                                                           registrations#cancel
                   new_user_registration GET    /users/sign_up(.:format)                                                                          registrations#new
                  edit_user_registration GET    /users/edit(.:format)                                                                             registrations#edit
                       user_registration PATCH  /users(.:format)                                                                                  registrations#update
                                         PUT    /users(.:format)                                                                                  registrations#update
                                         DELETE /users(.:format)                                                                                  registrations#destroy
                                         POST   /users(.:format)                                                                                  registrations#create
                                sessions GET    /sessions/login(.:format)                                                                         sessions#new
                                         POST   /sessions/login(.:format)                                                                         sessions#create
                                         GET    /sessions/logout(.:format)                                                                        sessions#destroy
                     line_login_sessions GET    /sessions/login_with_line(.:format)                                                               sessions#login_with_line
                               calendars GET    /calendars(.:format)                                                                              calendars#index
                                         POST   /calendars(.:format)                                                                              calendars#create
                            new_calendar GET    /calendars/new(.:format)                                                                          calendars#new
                           edit_calendar GET    /calendars/:id/edit(.:format)                                                                     calendars#edit
                                calendar GET    /calendars/:id(.:format)                                                                          calendars#show
                               schedules POST   /schedules(.:format)                                                                              schedules#create
                            new_schedule GET    /schedules/new(.:format)                                                                          schedules#new
                           edit_schedule GET    /schedules/:id/edit(.:format)                                                                     schedules#edit
                                schedule PATCH  /schedules/:id(.:format)                                                                          schedules#update
                                         PUT    /schedules/:id(.:format)                                                                          schedules#update
                                         DELETE /schedules/:id(.:format)                                                                          schedules#destroy
                  autocomplete_exercises GET    /exercises/autocomplete(.:format)                                                                 exercises#autocomplete
                               exercises GET    /exercises(.:format)                                                                              exercises#index
                                exercise GET    /exercises/:id(.:format)                                                                          exercises#show
                                         GET    /exercises/autocomplete(.:format)                                                                 exercises#autocomplete
                                         GET    /exercises(.:format)                                                                              exercises#index
                                         GET    /exercises/:id(.:format)                                                                          exercises#show
                        new_registration GET    /registrations/new(.:format)                                                                      registrations#new
                       line_registration GET    /line_registration(.:format)                                                                      registrations#line_registration
                      email_registration GET    /email_registration(.:format)                                                                     registrations#email_registration
           rails_postmark_inbound_emails POST   /rails/action_mailbox/postmark/inbound_emails(.:format)                                           action_mailbox/ingresses/postmark/inbound_emails#create
              rails_relay_inbound_emails POST   /rails/action_mailbox/relay/inbound_emails(.:format)                                              action_mailbox/ingresses/relay/inbound_emails#create
           rails_sendgrid_inbound_emails POST   /rails/action_mailbox/sendgrid/inbound_emails(.:format)                                           action_mailbox/ingresses/sendgrid/inbound_emails#create
     rails_mandrill_inbound_health_check GET    /rails/action_mailbox/mandrill/inbound_emails(.:format)                                           action_mailbox/ingresses/mandrill/inbound_emails#health_check
           rails_mandrill_inbound_emails POST   /rails/action_mailbox/mandrill/inbound_emails(.:format)                                           action_mailbox/ingresses/mandrill/inbound_emails#create
            rails_mailgun_inbound_emails POST   /rails/action_mailbox/mailgun/inbound_emails/mime(.:format)                                       action_mailbox/ingresses/mailgun/inbound_emails#create
          rails_conductor_inbound_emails GET    /rails/conductor/action_mailbox/inbound_emails(.:format)                                          rails/conductor/action_mailbox/inbound_emails#index
                                         POST   /rails/conductor/action_mailbox/inbound_emails(.:format)                                          rails/conductor/action_mailbox/inbound_emails#create
       new_rails_conductor_inbound_email GET    /rails/conductor/action_mailbox/inbound_emails/new(.:format)                                      rails/conductor/action_mailbox/inbound_emails#new
      edit_rails_conductor_inbound_email GET    /rails/conductor/action_mailbox/inbound_emails/:id/edit(.:format)                                 rails/conductor/action_mailbox/inbound_emails#edit
           rails_conductor_inbound_email GET    /rails/conductor/action_mailbox/inbound_emails/:id(.:format)                                      rails/conductor/action_mailbox/inbound_emails#show
                                         PATCH  /rails/conductor/action_mailbox/inbound_emails/:id(.:format)                                      rails/conductor/action_mailbox/inbound_emails#update
                                         PUT    /rails/conductor/action_mailbox/inbound_emails/:id(.:format)                                      rails/conductor/action_mailbox/inbound_emails#update
                                         DELETE /rails/conductor/action_mailbox/inbound_emails/:id(.:format)                                      rails/conductor/action_mailbox/inbound_emails#destroy
new_rails_conductor_inbound_email_source GET    /rails/conductor/action_mailbox/inbound_emails/sources/new(.:format)                              rails/conductor/action_mailbox/inbound_emails/sources#new
   rails_conductor_inbound_email_sources POST   /rails/conductor/action_mailbox/inbound_emails/sources(.:format)                                  rails/conductor/action_mailbox/inbound_emails/sources#create
   rails_conductor_inbound_email_reroute POST   /rails/conductor/action_mailbox/:inbound_email_id/reroute(.:format)                               rails/conductor/action_mailbox/reroutes#create
                      rails_service_blob GET    /rails/active_storage/blobs/redirect/:signed_id/*filename(.:format)                               active_storage/blobs/redirect#show
                rails_service_blob_proxy GET    /rails/active_storage/blobs/proxy/:signed_id/*filename(.:format)                                  active_storage/blobs/proxy#show
                                         GET    /rails/active_storage/blobs/:signed_id/*filename(.:format)                                        active_storage/blobs/redirect#show
               rails_blob_representation GET    /rails/active_storage/representations/redirect/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations/redirect#show
         rails_blob_representation_proxy GET    /rails/active_storage/representations/proxy/:signed_blob_id/:variation_key/*filename(.:format)    active_storage/representations/proxy#show
                                         GET    /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format)          active_storage/representations/redirect#show
                      rails_disk_service GET    /rails/active_storage/disk/:encoded_key/*filename(.:format)                                       active_storage/disk#show
               update_rails_disk_service PUT    /rails/active_storage/disk/:encoded_token(.:format)                                               active_storage/disk#update
                    rails_direct_uploads POST   /rails/active_storage/direct_uploads(.:format)                                                    active_storage/direct_uploads#create

となり、rails sを行うと、無事に飛ぶことができました!!

tmtkzk0823 commented 6 months ago

おめでとうございます🎉🎉🎉🎉🎉🎉🎉🎉🎉 上記で解決で大丈夫でしょうか?