pine0619 / enpit_omusubi

0 stars 4 forks source link

映えてる写真を増やす(20枚くらい) #48

Open pine0619 opened 3 years ago

pine0619 commented 3 years ago

手動でデータをテーブルに保存する方法(ローカル)

コンテナ立ち上げ docker-compose up -d

DBのmigrate docker-compose exec web rake db:migrate

railsコンソールの立ち上げ docker-compose exec web rails c

立ち上がったコンソール内でデータを入れる

Image.create(place_name: "Hally’s Cafe", longitude: 26.245671, latitude: 127.739715, image_path: "hallys_cafe.jpg", instagram_link: "https://www.instagram.com/p/CGl2mKdnJqD/?utm_source=ig_web_copy_link")
Image.create(place_name: "麺道くろとん 宜野湾店", longitude: 26.262737, latitude: 127.752032, image_path: "kuroton.jpg", instagram_link: "https://www.instagram.com/p/CG30k5anzWr/?utm_source=ig_web_copy_link")
Image.create(place_name: "備瀬フクギの森", longitude: 26.702644, latitude: 127.881007, image_path: "hukugi.jpg")
Image.create(place_name: "ライカム", image_path: "rycom.jpg")
Image.create(place_name: "伊江水道", image_path: "ie_suidou.jpg")
Image.create(place_name: "名護湾", image_path: "nago_bay.jpg")

用意している画像全部分データを入れる

Naha192839 commented 3 years ago

docker-compose exec web rake db:migrate する前に docker-compose exec web ./bin/rails db:rollback してデータベースに入っているデータがすべてリセットする

pine0619 commented 3 years ago

herokuでDBに保存する方法 写真はpublicに入れておく。

  1. herokuの右上あたりのMoreからRun consoleを選ぶ。
  2. heroku run rails cをする
  3. コンソールが出てきたら、
    Image.create(place_name: "Hally’s Cafe", longitude: 26.245671, latitude: 127.739715, image_path: "hallys_cafe.jpg", instagram_link: "https://www.instagram.com/p/CGl2mKdnJqD/?utm_source=ig_web_copy_link")
    Image.create(place_name: "麺道くろとん 宜野湾店", longitude: 26.262737, latitude: 127.752032, image_path: "kuroton.jpg", instagram_link: "https://www.instagram.com/p/CG30k5anzWr/?utm_source=ig_web_copy_link")
    Image.create(place_name: "備瀬フクギの森", longitude: 26.702644, latitude: 127.881007, image_path: "hukugi.jpg")
    Image.create(place_name: "ライカム", image_path: "rycom.jpg")
    Image.create(place_name: "伊江水道", image_path: "ie_suidou.jpg")
    Image.create(place_name: "名護湾", image_path: "nago_bay.jpg")
    Image.create(place_name: "古宇利島", image_path: "kirei.jpg")
    Image.create(place_name: "首里城", image_path: "kirei_shurijo.jpg")
    Image.create(place_name: "奥武島", image_path: "Ou_Island.jpg")
    Image.create(place_name: "那覇バスターミナル", image_path: "naha_bus_terminal.jpg")
    Image.create(place_name: "アメリカンビレッジ", image_path: "mihama.jpg")
    Image.create(place_name: "ウミカジテラス", image_path: "umikazi.jpg")

    って感じでDBに入れていく。必須なのは、place_nameと、image_path