I have an a Rails 3.2 App that show an error for Route not found in production
but not in development. I ran rake Route on my local machine and on the server and the text below show they are identical. I checked the route config file and it was identical and the views were the same. THe exact message I get in production is:
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
The two outputs from rakes routes is:
Rake Route Development:
harvest GET /harvest(.:format) visits#harvest
Rake Route from Production
harvest GET /harvest(.:format) visits#harvest
I am stumped is there anything else to look at. THe local machine is a Macbook the server is Centos
Related
I am trying to find a way to check logs or debug in production I am using passenger and apache and ubuntu as server. Every time I create any scaffold and upload it to server I get error :
I have used
bundle exec rake assets:precompile RAILS_ENV=production
But getting no success but when I am running application using :
rails s -e production
I can access my controllers and views over port 3000. What is wrong with this why assets:precompile is not working properly I am adding JS files manually not using coffee script. And my javascripts files are not complied.
My question is how can I set anything in production to see a debug like in development mode like this:
Can I do this in production I am using rails 5
The production error you have shown above was a 404 error. it means that the route doesn't exist or there are no controllers methods for that route or is a model not found error.
As for adding debuggers in production, can you do it?
Yes you can.
But should you do it?
NO, because it is a BAD practice. If you wish to view and debug errors in production, check your logs for the stacktrace and work with it from there. As long as it is a rails error, it will be in log/production.log.
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]
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.
I've succesfully submitted my app to git, and then pushed it to heroku. Starting page working as it has to, but the rest with path heroku_site.com/pages/page_name says me "We're sorry, but something went wrong." Same pages works fine on local server.
Any ideas whats wrong?
inb4 routes are fine(and rest too, rspec spec/ green)
You can view your Heroku logs with $ heroku logs
Looking at your routs, I'd guess that your page is based on content in your local database that you have not added yet to your production database.
If so, you can either push your local database to production $ heroku db:push
Or you can put that data in a Rails migration or seed it. Or you can go create it in your production app.
In general, to find out what you can do: $ heroku help
I am new to rails and I was able to install rails (3.2.3, ruby v1.9.3), then created a test app:
$ rails new Hello
then I cd'd into the new directory 'hello' and did the following commands:
$ rails generate controller home index
$ rails s
$ rake routes, it gave me
home_index GET /home/index(.:format) home#index
hello /hello(.:format) Hello#index
Then I pointed my browser to: http://localhost:3000/home/index - and it worked great.
Then I wanted to begin a tutorial and it asked me to create a new rails application
so I did like I did before...
$ rails new TutorialApp
$ rails generate controller tutorial index
$ rails s
$ rake routes, it gave me
tutorial_index GET /tutorial/index(.:format) tutorial#index
then I pointed my browser to: http://localhost:3000/tutorial/index, it gave me a message of
Routing Error
No route matches [GET] "/tutorial/index" Try running rake routes for
more information on available routes.
So I ran rake routes again, which it gave me the same output as it did before
tutorial_index GET /tutorial/index(.:format) tutorial#index
Since I created that first rails app "Hello", do I need to turn off that app before starting the new rails app "Tutorial" or they can both be running at the same time?
Any help is appreciated, thanks!
You can use a different port
rails server -p 3001
It will run in a different port. Then, just point to http://localhost:3001
But usually you will probably stop the server on one app and start the other one. It's up to you.
When you run rails server ("rails s"), you're typically running it in the context of the rails project you're in at the time, so before beginning a new project, I would shut down the current server (CTRL C). Also, make sure you create a new rails app in a folder is isn't itself at the root of a rails app. It looks like you might have created your tutorial app inside the root of your Hello app. Sounds like those are the two main things that tripped you up.