ga-wdi-exercises / project2

[project]
1 stars 30 forks source link

deploying to heroku #848

Closed Nykke closed 7 years ago

Nykke commented 7 years ago

I'm getting this error

remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to shrouded-wildwood-13767.
remote: 
To https://git.heroku.com/shrouded-wildwood-13767.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/shrouded-wildwood-13767.git'
nayana487 commented 7 years ago

This is usually due to some error in your CSS. Try running your CSS through a validator: https://jigsaw.w3.org/css-validator/

amaseda commented 7 years ago

Also take a look at the heroku logs. If you have the Rails 12 Factor gem installed, there might be some helpful info in there...

Nykke commented 7 years ago

sooo now I'm getting this issue

screen shot 2017-03-01 at 2 26 00 pm
amaseda commented 7 years ago

The error in the browser won't be too helpful. Have you taken a look at heroku logs? Any specific error mentioned in there?

Nykke commented 7 years ago

so this looks like my error but my relation is set up

ActionView::Template::Error (PG::UndefinedTable: ERROR:  relation "categories" does not exist
2017-03-01T19:25:39.684359+00:00 app[web.1]: LINE 1: SELECT "categories".* FROM "categories"
2017-03-01T19:25:39.684360+00:00 app[web.1]:                                    ^
2017-03-01T19:25:39.684637+00:00 app[web.1]: F, [2017-03-01T19:25:39.684588 #4] FATAL -- : [8f1c348f-a289-4a89-bbaf-6149f3904b23]     1: <h2> Welcome to Recipe Ting! The place where the people are friendly and the dishes are scrumptous! </h2>

and this

2017-03-01T19:25:39.682958+00:00 app[web.1]: I, [2017-03-01T19:25:39.682904 #4]  INFO -- : [8f1c348f-a289-4a89-bbaf-6149f3904b23]   Rendered categories/index.html.erb within layouts/application (34.7ms)
2017-03-01T19:25:39.683216+00:00 app[web.1]: I, [2017-03-01T19:25:39.683154 #4]  INFO -- : [8f1c348f-a289-4a89-bbaf-6149f3904b23] Completed 500 Internal Server Error in 45ms (ActiveRecord: 8.7ms)
2017-03-01T19:25:39.684273+00:00 app[web.1]: F, [2017-03-01T19:25:39.684219 #4] FATAL -- : [8f1c348f-a289-4a89-bbaf-6149f3904b23]
superbuggy commented 7 years ago

This might have to do with the order of your migrations, is your categories being created AFTER something is trying to reference it?

superbuggy commented 7 years ago

Or wait, did you heroku run rails db:migrate yet?

Nykke commented 7 years ago

no I didn't do that part yet do I do the drop and create and migrate and seeds too?

superbuggy commented 7 years ago

heroku does that stuff for you. just heroku run rails db:migrate

Nykke commented 7 years ago

okay so I did that and can view my app but my seeds are not present....

superbuggy commented 7 years ago

nice! now run heroku run rails db:seed

Nykke commented 7 years ago

yay!!! thank-you!

and I can edit and style and push my work onto here now right?

superbuggy commented 7 years ago

yes! closing for now

Nykke commented 7 years ago

soooo ummm my seeds doesn't show on my other pages but everything still works so I guess I have to just create everything again?

amaseda commented 7 years ago

What do you mean "show on my other pages"? Does it only show up on one page of your deployed app?

If you run heroku run rails db:seed, your seeds should show up throughout your deployed app.

Nykke commented 7 years ago

yeahhhh that doesn't happen unfortunately.

https://recipeting.herokuapp.com/

amaseda commented 7 years ago

Can you...

Nykke commented 7 years ago

seeds

equire 'active_record'
require_relative './recipe_data.rb'

Recipe.destroy_all
Comment.destroy_all

beverages = Category.create!(name: "beverages", img_url:"http://www.dietdetective.com/wp-content/uploads/summer-drinks1.jpg")

appetizers = Category.create!(name: "appetizers", img_url:"https://www.pillsbury.com/-/media/pb/images/recipes-hero/appetizers/bacon-cheddar-pinwheels-hero.ashx")

main_dish = Category.create!(name: "main dish", img_url:"http://images.parenting.mdpcdn.com/sites/parenting.com/files/styles/story_detail_enlarge/public/1100_story_quick_easy_family_meals.jpg?itok=PaRX6gt7")

dessert = Category.create!(name: "dessert", img_url:"http://eskipaper.com/images/dessert-1.jpg")

drink_one = Recipe.create!(title: "Ginger Beer", img_url:"http://www.seriouseats.com/recipes/assets_c/2012/01/20120130-189715-ginger-beer-thumb-625xauto-214181.jpg", ingredients:
  "1 1/2 lb green ginger, 4 lb brown sugar, 1 1/2 gallons water, 1 lemon sliced, handful of cinnamon, handful of cloves, handful of rice",
directions:
  "Step 1. Grate ginger., Step 2. Add sugar to water and stir until dissolved., Step 3. Pour mixture onto grated ginger. , Step 4. Add lemon slices; cinnamon; cloves and rice., Step 5. Cover and leave for three days., Step 6. Strain mixture and enjoy.", category: beverages)

 appetizer_one = Recipe.create!(title: "Mini Burgers", img_url:"http://bonappetitcrepecompany.com/wp-content/uploads/2016/04/mini-burger-4.jpg",
 ingredients:
   "1 lb ground chuck, 1/4 lb boneless short rib; minced, 6 mini brioche buns; split and toasted, Ketchup and pickle slices for serving",
   directions:
     "Step 1. Light a grill., Step 2. Combine the chuck and short rib; season with salt and pepper., Step 3. Form the meat into six patties., Step 4. Grill over high heat; turn once- about six minutes for medium-rare., Step 5. Place burgers on the toasted buns; top with ketchup and pickles.", category: appetizers)

   main_dish_one = Recipe.create!(title: "Prawn Curry", img_url:"http://goodtoknow.media.ipcdigital.co.uk/111/00000cb72/19ad/Prawn-coconut-curry.jpg",
   ingredients:
     "1 lb prawns, 1 small coconut, 1/4 lb onion, 3 cloves garlic, 2 tsb gheera, 2 bay leaves, salt to taste, 1 tbs ghee, 1/4 pint oil, pepper to taste, 2 tsp tumeric,
     1/2 oz curry powder",
     directions:
     "Step 1. Grate coconut. Set aside 2 tbsp of it. Add 1/2 pint water to rest of grated coconut and squeeze out milk., Step 2. Chop onions and garlic; put oil in pot and fry lightly with bay leaves., Step 3. Add tumeric; curry powder and gheera and fry for a minute., Step 4. Add prawns and grated coconut, salt and pepper. Fry for a few minutes., Step 5. Add coconut milk; stir and cover pot. Boil on medium heat until prawns are cooked; about five minutes., Step 6. Add ghee before removing from heat., Step 7. Serve hot with rice; sprinkled with rest of grated coconut.", category: main_dish)

   dessert_one = Recipe.create!(title: "Homemade Ice Cream", img_url:"http://getinspiredeveryday.com/food/wp-content/uploads/sites/5/2013/11/Homemade-Maple-Ice-Cream-GI-365-61.jpg",
   ingredients:
     "1 pint milk, 2 tbsp cornstarch or custard powder, 3 eggs, 2 oz sugar, flavoring (if desired)",
   directions:
     "Step 1. Blend custard powder with a little cold milk., Step 2. Heat the rest of the milk and add to blended custard powder., Step 3. Bring to boil and let it boil for about 3 minutes. Remove from the heat., Step 4. Add boiled mixture to beaten egg and sugar immediately; stirring all the time. Add flavoring., Step 5. Cool and Freeze., Step 6. Enjoy.", category: dessert)

     comment_drink = Comment.create!(title: "Best Ginger Beer Recipe EVER!!!", author: "Lynette", body: "This recipe was so easy to follow and I can't believe how authentic tasting it came out! Thank-you for sharing this fab recipe!", recipe: drink_one)
     comment_appetizer = Comment.create!(title: "Not too sure about these burgers", author: "Ariel", body: "I was a little disappointed in this recipe, I'm not sure what went wrong but they certainly didn't taste like the real deal.", recipe: appetizer_one)
     comment_main_dish = Comment.create!(title: "Spicy GOODNESS!!", author: "Marie", body: "OH EM GEE! This is the best damn thing I've ever had in my life! Thank-you for posting this recipe!", recipe: main_dish_one)
     comment_dessert = Comment.create!(title: "Delicious goodness or Flop?", author: "LaToya", body: "this ice cream all depends on the type of custard powder used which a little bit of a disappointment but nevertheless, still a great recipe.", recipe: dessert_one)

https://recipeting.herokuapp.com/categories/1

amaseda commented 7 years ago

Can you run heroku run rails db:seed again and check to see if there are any new errors in heroku logs? Wondering if something is silently failing...

@Nykke

Nykke commented 7 years ago

no it's not running anything and I'm getting this error

rails aborted!
ActiveRecord::RecordInvalid: Validation failed: User must exist
amaseda commented 7 years ago

Sounds like something that's supposed to be associated with a user (either a Recipe or Comment) is missing one.

I can see you making some in your seed file that don't have a user. So you either need to...

class Recipe < ApplicationRecord
  belongs_to :user, optional: true
end

You would need to do this for all models that belong to a user

Nykke commented 7 years ago

ahhh oh okay thanks

amaseda commented 7 years ago

Closing this for now but feel free to re-open if you have more questions/comments on this issue!