前提・実現したいこと
docker内でrails,mysqlを用いて他己紹介サービスを作っています。
困っているのが投稿系のテーブルにどういうデータを持たせるかと言うところです。
投稿テーブルに紹介した人(user_id)、された人(to_user)を持たせようと思っていますが、された人の情報をどのように取得すればイイのかわからず、アドバイスをいただきたです。
サービス内容としては、SNS経由でログインし、他己紹介をしてほしいSNSの友達に向けてAPIを使いSNSで要請文を送り、ログインしてもらって書いていただく。それをサービス内のマイページに表示させる。と言うものです。
発生している問題・エラーメッセージ
紹介された人の情報を取得できない。
該当のソースコード
scema.rb
schema.rb
1ActiveRecord::Schema.define(version: 2019_05_08_084527) do 2 3 create_table "introduces", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| 4 t.text "relation" 5 t.text "category" 6 t.text "content" 7 t.text "to_user" 8 t.bigint "user_id" 9 t.datetime "created_at", null: false 10 t.datetime "updated_at", null: false 11 t.index ["user_id"], name: "index_introduces_on_user_id" 12 end 13 14 create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| 15 t.text "relation" 16 t.text "category" 17 t.text "content" 18 t.text "to_user" 19 t.bigint "user_id" 20 t.datetime "created_at", null: false 21 t.datetime "updated_at", null: false 22 t.index ["user_id"], name: "index_introduces_on_user_id" 23 end 24 25 create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| 26 t.string "email", default: "", null: false 27 t.string "encrypted_password", default: "", null: false 28 t.string "reset_password_token" 29 t.datetime "reset_password_sent_at" 30 t.datetime "remember_created_at" 31 t.integer "sign_in_count", default: 0, null: false 32 t.datetime "current_sign_in_at" 33 t.datetime "last_sign_in_at" 34 t.string "current_sign_in_ip" 35 t.string "last_sign_in_ip" 36 t.string "confirmation_token" 37 t.datetime "confirmed_at" 38 t.datetime "confirmation_sent_at" 39 t.string "unconfirmed_email" 40 t.integer "failed_attempts", default: 0, null: false 41 t.string "unlock_token" 42 t.datetime "locked_at" 43 t.datetime "created_at", null: false 44 t.datetime "updated_at", null: false 45 t.string "provider" 46 t.string "uid" 47 t.string "user_name" 48 t.string "image_url" 49 t.string "description" 50 t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true 51 t.index ["email"], name: "index_users_on_email", unique: true 52 t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true 53 t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true 54 end 55 56 add_foreign_key "introduces", "users" 57end 58
この構造の方が安全面でもイイんじゃない?などのアドバイスなどあればいただきたいです( ´Д`)y━・~~
あなたの回答
tips
プレビュー