Skip to content

Commit

Permalink
seeds change
Browse files Browse the repository at this point in the history
  • Loading branch information
hjj2895 committed Sep 29, 2023
1 parent 6d4bc28 commit 63dc5f7
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 20 deletions.
4 changes: 2 additions & 2 deletions config/initializers/cors.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
# origins 'http://localhost:3001'
origins 'https://pintpal.onrender.com'
origins 'http://localhost:3001'
# origins 'https://pintpal.onrender.com'
resource '*',
headers: ["Authorization"],
expose: ["Authorization"],
Expand Down
50 changes: 32 additions & 18 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,40 @@
#
# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
# Character.create(name: "Luke", movie: movies.first)
require 'csv'


user1 = User.where(email: "[email protected]", username: "beerlover").first_or_create(password: "password", password_confirmation: "password")

user2 = User.where(email: "[email protected]", username: "brewlover").first_or_create(password: "password", password_confirmation: "password")

beer1 = Beer.create(
name: "Modelo Especial",
style: "Pilsner-style Lager",
abv: 4.4,
description: "An orange blossom honey aroma with a hint of herb.",
image_url: "https://www.modelousa.com/cdn/shop/files/Especial-02_0_1024x1024.jpg?v=1638951577"
)
beer_objects = {}

CSV.foreach(Rails.root.join('lib/seed_csv/beer-list.csv'), headers: true) do |row|
Beer.create( {
name: row["name"],
style: row["style"],
abv: row["abv"],
description: row["description"],
image_url: row["image_url"]
}
)
end
# beer1 = Beer.create(
# name: "Modelo Especial",
# style: "Pilsner-style Lager",
# abv: 4.4,
# description: "An orange blossom honey aroma with a hint of herb.",
# image_url: "https://www.modelousa.com/cdn/shop/files/Especial-02_0_1024x1024.jpg?v=1638951577"
# )

beer2 = Beer.create(
name: "Dos Equis Lager Especial",
style: "Golden Pilsner-style",
abv: 4.2,
description: "Balanced composition and a smooth, clean finish, it’s the party guest who is always invited and never overstays his welcome.",
image_url: "https://static.specsonline.com/wp-content/uploads/2022/11/007231163012-1.jpg"
)
# beer2 = Beer.create(
# name: "Dos Equis Lager Especial",
# style: "Golden Pilsner-style",
# abv: 4.2,
# description: "Balanced composition and a smooth, clean finish, it’s the party guest who is always invited and never overstays his welcome.",
# image_url: "https://static.specsonline.com/wp-content/uploads/2022/11/007231163012-1.jpg"
# )

review1 = [
{
Expand All @@ -38,7 +52,7 @@
Overall...I would not buy this too many times a year but I don't buy many non craft pilsners at all soo...It is great on a hot day and some good eats . great vacation beer or staycation . I gotta be honest these are cooler dwellers from vaca....so gifted cheers",
rating: 3,
user_id: 1,
beer_id: beer1.id
beer_id: Beer.find_by(name: "Modelo Especial")&.id
},
{
username: user1.username,
Expand All @@ -47,7 +61,7 @@
review_text: "I've had better",
rating: 1,
user_id: 1,
beer_id: beer2.id
beer_id: Beer.find_by(name: "Dos Equis Lager Especial")&.id
}
]

Expand All @@ -60,7 +74,7 @@
review_text: "12 oz can (I don't drink from green beer bottles). Better than I thought it would be, not as good as I hoped it would be. Pretty balanced overall - not too bitter or sweet, just the right amount of bubbles. Definitely one of the better adjuncts. High end lawn mower beer. It'll definitely do when icy cold!",
rating: 4,
user_id: 2,
beer_id: beer2.id
beer_id: Beer.find_by(name: "Dos Equis Lager Especial")&.id
},
{
username: user2.username,
Expand All @@ -69,7 +83,7 @@
review_text: "This is the best beer you can buy at 7-Eleven. It has a decent amber color, and it tastes good. Like Beer. It's fairly smooth, without an unpleasant aftertaste. It's a step above your average adjunct lager. When I'm tired of the heaviness of stouts, and the bitterness of IPAs, I enjoy a glass of this beer. It reminds me of when I was young, having a beer with my dad, or drinking with my friends.",
rating: 4,
user_id: 2,
beer_id: beer1.id
beer_id: Beer.find_by(name: "Modelo Especial")&.id
}
]

Expand Down
Loading

0 comments on commit 63dc5f7

Please sign in to comment.