前提・実現したいこと
Ruby on Rails 5で記事を管理するためのシステムを作っています。
ホーム画面から記事一覧画面に遷移する実装中に以下のエラーメッセージが発生しました。
発生している問題・エラーメッセージ
ActionView::Template::Error (undefined local variable or method `show_article_path' for #<#Class:0x00007fa401f2c180:0x00007fa4072621d8>):
1: h1 ホーム画面
2:
3: = link_to '記事一覧', show_article_path, class: 'btn btn-primary'
app/views/articles/index.html.slim:3:in `_app_views_articles_index_html_slim___2034070723339103860_70171235652860'
該当のソースコード
<index.html.slim>
h1 ホーム画面
= link_to '記事一覧', show_article_path, class: 'btn btn-primary'
<routes.rb>
Rails.application.routes.draw do
root to: 'articles#index'
resources :articles
end
<articles_controller.rb>
class ArticlesController < ApplicationController
def index
end
def show
end
def new
end
def edit
end
end
試したこと
'resources :articles'によって、URLヘルパーメソッドは定義されているはずなのですが、`show_article_path'が定義されていないというエラーが出てきて困っています。
よろしくお願いします。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/28 06:05