Ruby on Railsの教材を見ながらマッチング機能を実装しようとしてるのですがこのエラーが出て原因が究明できずつまづいています。
教材がsqliteだったのですが私がローカル環境をpostgreSQLで設定していたので、postgreSQlで進めたのが原因かと思われます。
分かる方いらっしゃいましたらアドバイスよろしくお願いいたします。
app/controllers/matching_controller.rb
Ruby
1class MatchingController < ApplicationController 2 def index 3 got_reaction_user_ids = Reaction.where(to_user_id: current_user.id, status: 'like').pluck(:from_user_id) 4 @match_users = Reaction.where(to_user_id: got_reaction_user_ids, from_user_id: current_user.id, status: 'like').map(&:to_user) 5 end 6end 7
db/migrate/create_reactions.rb
Ruby
1class CreateReactions < ActiveRecord::Migration[5.2] 2 def change 3 create_table :reactions do |t| 4 t.integer :to_user_id, null: false 5 t.integer :from_user_id, null: false 6 t.integer :status, null: false 7 t.timestamps 8 end 9 end 10end
app/models/reaction.rb
ruby
1class Reaction < ApplicationRecord 2 belongs_to :to_user, class_name: "User" 3 belongs_to :from_user, class_name: "User" 4 enum status: { like: 0, dislike: 1 } 5 end
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/24 03:45 編集
2019/03/24 03:47
2019/03/24 03:51
2019/03/24 03:53
2019/03/24 04:21
2019/03/24 04:39
2019/03/24 04:44