ルーティングが間違っていると表示されうまくアクセスできません。
shool/topのviewは
<h1>学校を探しましょう</h1> <p><%= link_to("中学校一覧", "school/junior") %></p> <p><%= link_to("高等学校一覧", "school/high") %></p>で、ルーティングの設定は
get "school/junior_pref" => "schools#junior_pref"
get "school/high_pref" => "schools#high_pref"
get "school/top" => "schools#index"
となっています。
ちなみにコントローラは
class SchoolController < ApplicationController
def index
end
def junior_pref
end
def high_pref
end
end
となっています。
しかし、学校を探しましょうから各ページに飛ぼうとすると次のようなエラーが出ます
なぜか教えてください
Routing Error
No route matches [GET] "/school/school/junior_pref"
Rails.root: /Users/mycomp/Desktop/app
Application Trace | Framework Trace | Full Trace
Routes
Routes match in priority from top to bottom
Helper HTTP Verb Path Controller#Action
Path / Url
Path Match
school_index_path GET /school/index(.:format)
school#index
school_junior_path GET /school/junior(.:format)
school#junior
school_high_path GET /school/high(.:format)
school#high
POST /likes/:post_id/create(.:format)
likes#create
POST /likes/:post_id/destroy(.:format)
likes#destroy
schools_top_path GET /schools/top(.:format)
schools#top
schools_new_path GET /schools/new(.:format)
schools#new
POST /users/:id/update(.:format)
users#update
GET /users/:id/edit(.:format)
users#edit
users_create_path POST /users/create(.:format)
users#create
signup_path GET /signup(.:format)
users#new
users_index_path GET /users/index(.:format)
users#index
GET /users/:id(.:format)
users#show
login_path POST /login(.:format)
users#login
logout_path POST /logout(.:format)
users#logout
GET /login(.:format)
users#login_form
GET /users/:id/likes(.:format)
users#likes
posts_index_path GET /posts/index(.:format)
posts#index
posts_new_path GET /posts/new(.:format)
posts#new
GET /posts/:id(.:format)
posts#show
posts_create_path POST /posts/create(.:format)
posts#create
GET /posts/:id/edit(.:format)
posts#edit
POST /posts/:id/update(.:format)
posts#update
POST /posts/:id/destroy(.:format)
posts#destroy
GET /
home#top
about_path GET /about(.:format)
home#about
Request
Parameters:
None
Toggle session dump
Toggle env dump
Response
Headers:
None
x
OS:mac
Ruby 2.3.1
Rails 5.0.3
回答1件
あなたの回答
tips
プレビュー