プルダウンをデータベースから参照し、表示させたいと思っています。
プルダウンとして表示させるのは、メモ帳のカテゴリーです。
参照
https://qiita.com/colorrabbit/items/b58888506e41d1370fd1
collection_select の書き方が悪いのか、form_forの部分で以下のエラーが出てしまいます。
どういうことなのかよくわからないため、解決策を教えていただければと思います。
NoMethodError in Memochous#index /app/views/memochous/index.html.erb where line #5 raised: undefined method `memocategories_path' for #<#<Class:0x007fe3d08513d8>:0x007fe3ccad9b40> Did you mean? memochou_path
memochous_controller
def index @memochous = Memochou.all @memo = Memocategory.new end
/app/views/memochous/index.html.erb
<%= form_for @memo do |f| %> <%= f.collection_select :memocategory_id, Memocategory.all, :id, :category %> <% end %>
データベースは、メモ帳本体のモデル「Memochou」
memotitle text型
category integer型
とカテゴリー用モデル「Memocategory」
category text型
です。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/12/15 07:01