このサイトを見ながら、act_as_votableでいいね一覧を表示しようとしているのですが、no method errorが出てしまいます。
routes.rb↓
resources :songs do member do put "like", to: "songs#upvote" get 'like', to: "songs#like" end resources :comments do member do put "good", to: "comments#upvote" end end end
songs.controller ↓
def like @songs = current_user.votes.up.for_type(User).votables end
<%= @songs.each do |song| %> <%= song.title%> <% end %>
そもそも「votes.up.for」とはどこからきたのでしょうか?
スキーマを見てもそのようなものは見当たりません。
create_table "songs", force: true do |t| t.string "title" t.text "body" t.datetime "created_at" t.datetime "updated_at" t.integer "user_id" t.integer "get_upvotes" t.integer "cached_votes_total", default: 0 t.integer "cached_votes_score", default: 0 t.integer "cached_votes_up", default: 0 t.integer "cached_votes_down", default: 0 t.integer "cached_weighted_score", default: 0 t.integer "cached_weighted_total", default: 0 t.float "cached_weighted_average", default: 0.0 end
教えていただけると嬉しいです。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/10/16 14:05
2017/10/16 15:04
2017/10/17 12:24
2017/10/17 16:33
2017/10/17 21:34