Help with Heroku, don’t show pages with Ruby language?

Asked

Viewed 192 times

0

Hello, I need the help of the noble holders of knowledge. I am studying Ruby on Rails through the Codecademy website. I took some things I learned there, and I tried to put it online on Heroku. It all worked out right at first, everything perfect. But suddenly, when trying to enter a specific page, it showed the following error: Erro mostrado ao tentar acessar a página  NO SERVIDOR.

Such an error is not shown in localhost. So I decided to start from scratch and deploy every step to find the problem. The problem was that, a normal page with pure html, opens quietly, but one with Ruby (inside the file) gives this problem.

The following code is generating the problem (I believe)

<% @messages.each do |message| %>
      <div class="message">
        <p class="content"><%= message.content %></p>
        <p class="time"><%= message.created_at %></p>
      </div>
<% end %>

The link to if you want to check in person is this:

https://segundoteste.herokuapp.com/



It has 2 buttons, the "Messages!" button has the above snippet in the code and shows the error. And the Test button has no error and shows no error.


Would anyone like to spend some time to help me? It will be of great help. Thank you.

Updating:
Controller
This is the controller of the page with problem.

File inside db/migrate:
inserir a descrição da imagem aqui

Log:
inserir a descrição da imagem aqui

  • Welcome, start by doing the Tour, good you set up the route in routes.rb ?

  • Configured. Code follows: Rails.application.Routes.draw do <br> root 'pages#home' <br> get '/messages' => 'messages#index' <br> get '/testing' => 'testing#test' <br> # For Details on the DSL available Within this file, see <br>http://guides.rubyonrails.org/routing.html <br> end <br> No localhost works normally

  • Edith your question and put more information, how is this variable messages ... See on Heroku the application log.

  • Sorry ignorance, but how do I see the log? is what it shows after deploy?

  • https://devcenter.heroku.com/articles/logging

1 answer

0


People you see now, I’ve solved the problem

The problem was the database. There was no code table in Heroku’s database, because I hadn’t migrated it! How stupid of me. That’s why it worked on the localhost.
What I did was the second:

-- I checked the logs, a thank you to wmsouza (can’t score, go anyway) by reminding me that they exist.

-- In the logs he said that he had not been able to connect with the table "messages" in the database. Obviously. I hadn’t migrated her to the Heroku database, she was alone on my computer That’s why it didn’t work.

-- I found after so much searching, the page https://data.heroku.com/datastores that has the necessary data to make the connection.

-- I took this data and put it in the file database.yml.

-- I also connected my pgAdmin3 with this data.

-- I gave one rake db:migrate and a rake db:Seed. And that’s it, solved the problem, the page opens normally now, and shows the messages that are on the server.

That’s all.

Vlw the attention guys, I’m motivated again to learn Ruby on Rails

Browser other questions tagged

You are not signed in. Login or sign up in order to post.