tinderのswip機能を作成しています。swip機能は完成したのですが,like or dislikeしたuserがページを新しく読み込むとまたswipできてしまいます。一度swipしたuserを今後swip画面に表示しないようにするにはどうすればいいでしょうか?
いろいろ試したのですが、うまくいきませんでした
DB
1create_table "reactions", force: :cascade do |t| 2 t.bigint "to_user_id", null: false 3 t.bigint "from_user_id", null: false 4 t.integer "status", default: 3, null: false 5 t.datetime "created_at", precision: 6, null: false 6 t.datetime "updated_at", precision: 6, null: false 7 t.index ["from_user_id"], name: "index_reactions_on_from_user_id" 8 t.index ["to_user_id"], name: "index_reactions_on_to_user_id" 9 end 10 11create_table "users", force: :cascade do |t| 12 t.string "email", default: "", null: false 13 t.string "encrypted_password", default: "", null: false 14 t.string "reset_password_token" 15 t.datetime "reset_password_sent_at" 16 t.datetime "remember_created_at" 17 t.datetime "created_at", precision: 6, null: false 18 t.datetime "updated_at", precision: 6, null: false 19 t.string "name", null: false 20 t.integer "occupation", default: 0, null: false 21 t.text "self_introduction" 22 t.string "profile_image" 23 t.index ["email"], name: "index_users_on_email", unique: true 24 t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true 25 end 26
userrb
1has_many :reactions, dependent: :destroy 2
reactionrb
1belongs_to :to_user, class_name: "User" 2 belongs_to :from_user, class_name: "User" 3 4 enum status: { like: 0, dislike: 1 }
userContollor
1 2class UsersController < ApplicationController 3 before_action :authenticate_user! 4 5 def show 6 @user = User.find(params[:id]) 7 end 8 9 def index 10 @users = User.where.not(id: current_user.id).where.not(occupation: current_user.occupation) 11 @user = User.find(current_user.id) 12 end 13 14end 15
あなたの回答
tips
プレビュー