質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

2回答

2599閲覧

No route matches [GET] "/home/about"の解決方法

退会済みユーザー

退会済みユーザー

総合スコア0

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

1クリップ

投稿2020/07/18 00:10

前提・実現したいこと

Railsで現在、topページから順にメモアプリ作成中です。

発生している問題・エラーメッセージ

アプリ概要のページ(localhost:3000/home/about)を作成できたと思い、URLにアクセスしたところ
以下のエラーが発生しました。
###エラーメッセージ
No route matches [GET] "/home/about"

###ソースコード
routes.rb
Rails.application.routes.draw do
get "/" => "home#top"
get "about" =>"home#about"
end

home_controller.rb
class HomeController < ApplicationController
def top
end

def about
end

end

試したこと

Google検索などで解決方法の調査(解決に至らず)

補足情報(FW/ツールのバージョンなど)

rails 6.0.3.2にてアプリ作成中。
初学者なりの解釈ですが、本エラーはルーティングが無い・もしくは反映されていないために発生したエラーかと思います。
お手数おかけしますが、解決方法のご教授の程よろしくお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

ベストアンサー

ruby

1get "/home/about" =>"home#about"

でいけると思います!

投稿2020/07/18 00:15

ducci

総合スコア191

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2020/07/18 00:22

ご回答ありがとうございます。 ご回答にあるコードを入力しましたが、No route matches [GET] "/home/about" エラーが出ました。 routesやcontrollerの入力内容は問題ないと思うので、ターミナル側で何か作業が漏れているのでしょうか。
ducci

2020/07/18 00:34

一度railsを再起動してみてください。 もしくは `bundle exec rails routes` で表示されるルーティングを確認してみてください。
退会済みユーザー

退会済みユーザー

2020/07/18 01:09

再起動→同じエラーが発生しました。 bundle exec rails routesを実行し、ルーティングを確認したところ、以下のとおりでした。 Prefix Verb URI Pattern Controller#Action posts_index GET /posts/index(.:format) posts#index home_top GET /home/top(.:format) home#top index_post_index GET /index/post_index(.:format) index#post_index 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 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/:signed_id/*filename(.:format) active_storage/blobs#show rails_blob_representation GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#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 ルーティングが存在しないことは読み取れるのですが、追加方法が分からず詰んでいる状況です・・・。
退会済みユーザー

退会済みユーザー

2020/07/18 02:14

時間を置いて再起動後、解決しました! この度はお忙しい中ご回答いただき、ありがとうございました。
guest

0

このルーティングでは、/aboutが当該ページになります。/home/aboutではありません。

投稿2020/07/18 00:12

maisumakun

総合スコア145184

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2020/07/18 00:22

ご回答ありがとうございます。  localhost:3000/about でアクセスを試みましたが、No route matches [GET] "/about" エラーが出ました。 routesやcontrollerの入力内容は問題ないと思うので、ターミナル側で何か作業が漏れているのでしょうか。
退会済みユーザー

退会済みユーザー

2020/07/18 02:14

時間を置いて再起動後、解決しました! この度はお忙しい中ご回答いただき、ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問