Ruby on Railsでビューファイルへアクセスしたいのですが
URLがわかりません。
config/routes.rb
Rails.application.routes.draw do
get 'blogs' => 'blogs#index'
get 'blogs' => 'blogs#eg'
end
app/controllers/blogs_controller.rb
class BlogsController < ApplicationController
def index
end
def eg end
end
というファイルを作成した場合に
app/views/index.html.erbとeg.html.erbにアクセスしたいのですが
URLがわかりません。
rails sでテストサーバーを起動して
http://localhost:3000/blogsと検索するとindexファイルは表示されるのですが
http://localhost:3000/blogs/index.html.erbや
http://localhost:3000/blogs/eg.html.erbと検索しても
Routing Error
No route matches [GET] "/blogs/index.html.erb"
Rails.root: /Users/name/projects/blogman
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
blogs_path GET /blogs(.:format) blogs#index
GET /blogs(.:format) blogs#eg
というエラーメッセージが表示されます。
正しいビューファイルの表示のさせ方を教えてください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/25 05:00
2018/12/25 05:02
2018/12/25 05:14