新規登録、編集、閲覧、削除までだけのノート的なものを作ろうとしているのですが、閲覧(show)がうまく動きません
どうすればうまく動きますか?
コードは下記の通りです
エラー画面は
routes.rb
Rails.application.routes.draw do resources :notes root 'notes#index' end
notes_controller.rb
class NotesController < ApplicationController def index @notes = Note.all end def new @note = Note.new end def create @note = Note.new(note_params) @note.save redirect_to notes_path end def show @note = Note.find(params[:id]) end private def note_params params[:note].permit(:day, :title, :about) end end
<h1>Show</h1> <h2><%= @note.day %></h2> <h1><%= @note.title %></h1> <p><%= @note.about %></p> show.html.erb
index.html.erb
<h1>HelloMyNotebook</h1> <% @notes.each do |note| %> <h2><%= note.day %></h2> <h1><%= note.title %></h1> <%= link_to "show", "/notes/show" %> <hr> <% end %>
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。