My app so far seems to be working, until I try to see it on Heroku. Checking my logs I see " Error: (No route matches [GET] “/”)"...
This is my routes.rb:
Rails.application.routes.draw do
get 'pages/landing_page'
get 'pages/contact'
get 'pages/about'
this is the Gemfile:
Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.7'
Use sqlite3 as the database for Active Record
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
app on github: https://github.com/nandoencinas/test_app
You don't have a route that matches to your root path ('/'). Which means when you go to your heroku and enter myheroku-app.com
Your application doesn't know which controller#action to send as a response.
However, if you put in myheroku-app.com/pages/landing_page
(by looking at your routes), you will see your landing_page.
If pages
is the name of your controller, and landing_page
is your action you can put this in config/routes.rb
:
root to: "pages#landing_page"
And now, when someone visits the root of your application (ie myheroku-app.com, they will be routed to your landing page
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.