Rails page not showing in Heroku - ruby-on-rails

I deployed a simple Rails project on Heroku and I'm having some trouble. I set my root page as:
root 'landing#index'
This page works fine when I cd into the project, and start rails server and go to localhost:3000. I pushed to Heroku without error using git push heroku master. However now, if I do heroku open, I get the following message on the page:
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
The logs don't show anything significant as well...

Make sure that you have the following:
A LandingController
A view page at the path app/views/landing/index.html.erb
root 'landing#index' on the second line (after Application.routes.draw)
The live repository is up to date
https://devcenter.heroku.com/articles/getting-started-with-rails4#write-your-app
Failing that, run heroku run rake routes. You should see a route like GET /landing/index landing#index and root / landing#index
If they don't appear, add the line resources :landing to generate the default routes for the landing controller.

Related

Rails Tutorial sample_app fails in Heroku with log: ActionController::RoutingError (No route matches [GET] "/about"):

I am following the online version of Rails Tutorial. The Sample_app in chapter 3 works fine locally, but when pushed to Heroku, the home page is found but not the other pages. Running heroku logs after trying to see the About page gives me (along with much else) the error above:
2015-08-09T02:56:43.916991+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/about"):
My routes.rb file is
Rails.application.routes.draw do
root 'static_pages#home'
get 'static_pages/help'
get 'static_pages/about'
end
I have followed the directions carefully. I tried deleting and recreating the Heroku file. I did web searches and tried some things to no avail. My gemfile is straight from the online version of the book, which is using current versions.
Solved: #thedanotto had me run heroku run rake routes which showed that the help and about pages were directed to {root}/static_pages/about rather than {root}/about. I am still puzzled why the tutorial gives the about routes, which appear not to work as expected, and welcome any further comment, but I am marking this as solved.
Whenever I can't find a route, I run the terminal command
rake routes
Since you're on heroku you'll want to run
heroku run rake routes
Which will return something similar to the following.
Prefix Verb URI Pattern Controller#Action
static_pages_about GET /static_pages/about(.:format) static_pages#about
So that shows that you can go to www.[heroku_app_name].herokuapp.com/static_pages/about And it will bring you to the page you want. You can also add a link to the page in a view by putting the following line of code within a view.
<%= link_to("About", static_pages_about_path) %>
That's all good stuff to know. But let's talk about using the controller action: static_pages#about with the path /about
Switch the following in routes.rb from
get 'static_pages/about'
to
get "static_pages/about", path:"/about"
or alternatively
get "/about", to: "rabbits#about"
You can read more about Routes here
If it works fine locally, I assume you've set up the controllers, views etc properly.
Have you made sure to commit all those necessary changes then push?
e.g.
git add .
git commit -am "Added route"
git push heroku master
Are you accessing the about page using the following URL ?
http://YourHerokuAppName.herokuapp.com/static_pages/about
[ Replace "YourHerokuAppName" with your Heroku App Name]

No errors, no problems, nothing showing up

I've spent a solid amount of time on this and I've lost faith in my Heroku abilities.
I have a rails app
I've migrated the database
I've included the rails12_factor gem in production
I have the Heroku toolbelt
I've logged in with my credentials via the terminal
I've created a heroku app with the command "heroku create blahblahblah"
This gave me my remote
I've used 'init' 'add .' 'commit' and everything is up to date
I've deployed with 'git push heroku master'
My app was deployed successfully without any problems
It tells me everything is up to date
My production check says everything passes
I can't for the life of me bloody well figure out why, when I go to my app's URL that it only shows the welcome page "Heroku | Welcome to your new app!"
I'd be forever greatful and in your debt to whomever can help me with this.
In older versions of rails you had to delete the index page from the public directory.
I think in rails 4, you need to define a route for root.
so in your config/routes.rb some thing like :
root to: 'static_pages#home'
Do you have this problem only on Heroku? what happens on localhost:3000?

Heroku open gives a 404

I'm deploying Rails on Heroku for the first time, so I accept I'm a bit of a newbie on this turf.
I installed the tool Heroku tool belt. Created a simple Rails application. Logged into Heroku. did..
heroku Create
And then pushed up the master
git push heroku master
Once the deployment is complete I tried
heroku open
I end up getting a 404. The app though runs fine on my local environment.
Heroku does not provide a standard welcome page for Rails 4. So if you did not create one yourself You will get a 404 page. This problem should not arise if your root to is properly set.
You can test this by creating a home controller with an index action, create the index. html.erb page and define root to: 'home#index'. Now heroku knows about the pageĀ and you will not receive a 404 error.
Getting started with heroku guide: https://devcenter.heroku.com/articles/getting-started-with-rails4

ruby on rails web development using heroku

my app is not been uploaded on
heroku
only the first page with welcome to ruby on rails is displayed
my url is
my url link
Your deployed app is presently being overridden by Rails' default static index page. From config/routes.rb:
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
Therefore, first ensure that your root route is set:
# config/routes.rb
root :to => `root_controller#root_action`
Then, delete public/index.html, commit the changes to version control, and redeploy to Heroku.
First make sure you have correct routes. Then you commit the changes to the master branch and then:
git push heroku master
Hope this helps.

heroku doesnt show my views. RoR project

So I am trying to upload a RoR project I am working on. So to make it more interesting I just changed the home page, instead of having the usual one. I deleted the public/index.html, created a static page controller and added a new home.html.erb file in my views folder. I also changed the config/routes file. It works fine on my localhost. then I run these
git add .
git commit -m "Added home page"
git push heroku master
heroku run rake db:migrate
heroku open
and for a homepage I get the usual RoR page instead of mine. What did I do wrong?
Try deleting public/index.html as that is probably getting served before hitting the app.

Resources