Web dev 101 - New Rails app - not working on web page


#1

Hi Guys, new here and going through web development 101 and i’m creating my first rails app and followed the instructions meticulously. Right at the end of this section, I entered ‘heroku open’ and the web page didn’t work. Please see the snippets.


#2

Hello RayPhe!

What happened after you tried heroku open? Did it open a webpage with an error?

It’s helpful to see everything, even if it’s just an empty line waiting for your next command in the terminal or a webpage with a nasty-looking error.


#3

Hi ZachBaird,

Thanks for your help.

As I am new, for some reason I can only attach one pic at a time.

Anyways, when I enter ‘heroku open’ on the terminal, it opens the browser but the page is not found.

Not sure if I’ve done something wrong with the set up but I doubt it as everything runs fine, it’s just this last part.

Would my Heroku logs help you understand?


#4

No problem! I didn’t know about the one pic limit.

Sure, feel free to share the logs. There’s also a Discord chat I highly encourage you to join. There’s loads of folks on there who can help you out faster than on the forum.

So the page 404s?


#5

Ok, it’s one pic per message :smiley:

Yeah, so I’m on discord also. The attachment is from the web browser and isn’t a 404.


#6

Just messaged you! We can work on the chat faster.

Once we find the solution, we’ll put it here for others to see if they’re stuck as well.


#7

Heroku logs -

2020-01-05T19:52:28.655084+00:00 app[web.1]: [3f11b7b2-2513-411a-ab43-2c12fb00286b] vendor/bundle/ruby/2.6.0/gems/puma-3.12.2/lib/puma/thread_pool.rb:135:in `block in spawn_thread’
2020-01-05T19:52:28.865335+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=safe-basin-49445.herokuapp.com request_id=6f18ceb4-eacd-4f2a-89f9-aedf23f3c2e2 fwd=“24.135.232.181” dyno=web.1 connect=1ms service=2ms status=200 bytes=143 protocol=https
2020-01-05T20:26:41.145372+00:00 heroku[web.1]: Idling
2020-01-05T20:26:41.148608+00:00 heroku[web.1]: State changed from up to down
2020-01-05T20:26:42.019016+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2020-01-05T20:26:42.020052+00:00 app[web.1]: === puma shutdown: 2020-01-05 20:26:42 +0000 ===
2020-01-05T20:26:42.020057+00:00 app[web.1]: - Goodbye!
2020-01-05T20:26:42.020137+00:00 app[web.1]: Exiting
2020-01-05T20:26:42.009208+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-01-05T20:26:42.095109+00:00 heroku[web.1]: Process exited with status 143


#8

We found the issue in the Discord chat.

After looking at more of the logs, RayPhe was receiving errors involving his Cars route not being recognized. After checking his routes.rb file in the /config/ folder, we saw that the root was:

root car#index

This is one letter off. See the below correct example:

Rails.application.routes.draw do
  root 'cars#index'
  resources :cars
  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end

We specified that there was a route cars with resources :cars, and then designate this resource as the root of our application. If we use car#index rather than cars#index, Rails won’t understand what car is.