getting RoutingError after upgrade to Rails 4 - ruby-on-rails

I have an application on Heroku, and after I update to Rails 4.1.0 I'm seeing these RoutingErrors exception:
Started GET "/assets/Elusive-Icons-5997c1a6679785a96defc4f57a3f2ff5.svg" for 177.16.216.169 at 2014-04-12 21:56:41 +0000
2014-04-12T21:56:41.397071+00:00 app[web.1]:
2014-04-12T21:56:41.397071+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets/Elusive-Icons-5997c1a6679785a96defc4f57a3f2ff5.svg"):
I installed rails_12factor and tried to put config.serve_static_assets = true on applicationl.rb but no effect. What am I missing?

As mentioned in the comments, you should input this into your cmd: rake assets:precompile RAILS_ENV=production -- this, coupled with deploying to Heroku, should solve the issue

Related

Rails 5 + Puma + Pow not working locally

I'm updating my rails app to 5.0.0.rc1 in a separate branch. App was already configured to run on puma 2.14, but I upgraded to puma 3.4.0 during the update process.
I ran rails update but kept my old puma config around because nothing changed except the plugins directive which I don't care about now.
Anyway, I cannot get my app to respond in development mode, but I deployed it a staging server to see if I could get better error logs and it actually works on staging.
Before, I could access my app locally using pow by visiting:
http://app.dev
Now, that doesn't work. Neither does:
bundle exec puma -C config/puma.rb config.ru
Nor does this:
bin/rails server puma
My logs just show something like this everytime:
Started GET "/" for 127.0.0.1 at 2016-05-27 09:11:39 -0400
Started GET "/" for 127.0.0.1 at 2016-05-27 09:11:44 -0400
Started GET "/" for 127.0.0.1 at 2016-05-27 09:11:47 -0400
Started GET "/" for 127.0.0.1 at 2016-05-27 09:11:50 -0400
They never make it to Rails for processing no matter how I attempt to start the server locally. And that's all the error info I get, too. Pow's logs are similarly useless.
Any ideas whats going on?
The emotional successor of pow(latest commit on the repo is from 6 November 2014) is puma-dev. According to their docs pow is a no-go for Rails 5. Maybe you should give it a go.

Heroku: The page you were looking for doesn't exist

I get this error when i try to deploy my app to Heroku. My first deployment works fine before I'm doing heroku run rake db:reset.
After this, I have errors below: "We're sorry, but something went wrong." and "The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved."
My heroku logs says:
2012-12-08T11:40:54+00:00 app[web.1]: ActionView::Template::Error (bootstrap.css isn't precompiled):
2012-12-08T11:40:54+00:00 app[web.1]: 9: <%= csrf_meta_tags %>
2012-12-08T11:40:54+00:00 app[web.1]:
2012-12-08T11:40:54+00:00 app[web.1]: 8: <%= javascript_include_tag "bootstrap", media: "all"%>
Some one, Can you help me ?
Looks like Heroku is complaining that your assets are not precompiled. I'd read through this tutorial about rails on heroku, there is a section dedicated to resource pre-compilation.
You can tell your application to precompile assets in production
#config/environments/production.rb
config.assets.compile = true
# Heroku also requires this to be false
config.assets.initialize_on_precompile=false
Or you can precompile your assets using the rake task
#before pushing to Heroku and then you can push
rake assets:precompile
#or after you've pushed to heroku
heroku run rake assets:precompile

RoutingError in Rails application on dreamhost

I want to test sample rails application on shared Dreamhost account, so i have created sample application with ruby 1.8.7, rails 3.2.8 and mysql database. on localhost it works fine, but after uploading it on Dreamhost its giving error when i clicks on "About your application’s environment" like given below.
here is the detail error from production.log file
Started GET "/rails/info/properties" for 180.87.200.112 at Sat Oct 06
01:38:01 -0700 2012
ActionController::RoutingError (No route matches [GET]
"/rails/info/properties"):
Started GET "/assets/rails.png" for 180.87.200.112 at Sat Oct 06
01:37:50 -0700 2012
ActionController::RoutingError (No route matches [GET]
"/assets/rails.png"):
Please make sure following in your production file.
config.assets.compile = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = true

RoutingError raised when using precompiled assets in production environment

Trying to test deploy a simple Rails 3.1 app in production mode, using the asset pipeline, after precompiling the assets. Using JRuby and WEBrick 1.3.1 for now; the plan is to deploy next on JBoss.
Everything works fine running in development environment, but in production it raises RoutingError when the client requests any precompiled asset.
The Rails server log looks like:
Started GET "/assets/application-a04f15ca8cb6078896dbdc22266757d9.css"
for 127.0.0.1 at 2012-02-06 18:19:04 -0500
ActionController::RoutingError (No route matches [GET]
"/assets/application-a04f15ca8cb6078896dbdc22266757d9.css)
The precompiled assets are in the applications public/assets directory.
Should I expect WEBrick to be able to handle /public/assets? or can I only test that when deployed on Apache or such?
Any help would be greatly appreciated.
The answer is at No route matches [GET] /assets
It makes sense. Rails in production mode doesn't serve static assets by default, leaving that to the deployment server. You can configure rails to serve static assets by setting config.serve_static_assets to true (though you probably get better performance leaving it as false)

How to set up a complete "hello world" site with rails 3.1 in production mode?

I'm struggling with setting up a rails-based web site in production mode. An intermediate goal would be to set up a very simple web site. I'm using Rails 3.1.0, rake 0.9.2.2, and
Ruby 1.9.2.
Here is what I tried, with unsuccessful results so far:
initially, make sure RAILS_ENV is not set
rails new test_project
cd test_project
rails generate scaffold User name:string email:string
rake db:migrate
rails s
browse to localhost:3000 or localhost:3000/users
things look OK.
now, attempt to set this up for production:
export RAILS_ENV=production
rake db:migrate
rake assets:precompile
rails s
browse to localhost:3000
PROBLEM: Routing Error; No route matches [GET] "/"
kill rails
in config/routes, add root :to => 'users#index'
rails s
can now browse to localhost:3000 and localhost:3000/users
BUT, rails generates the following errors:
Started GET "/assets/application-00960e5186894b532975562d59176a6a.css" for 127.0.0.1 at 2011-11-26 23:09:44 -0800
ActionController::RoutingError (No route matches [GET] "/assets/application-00960e5186894b532975562d59176a6a.css"):
Started GET "/assets/application-ae30e133eabbb10d9464189d3fb71e25.js" for 127.0.0.1 at 2011-11-26 23:09:44 -0800
ActionController::RoutingError (No route matches [GET] "/assets/application-ae30e133eabbb10d9464189d3fb71e25.js"):
Can anyone shed light on how to fix the above simple attempt to get a Rails 3.1 project working in "production" mode?
The fundamental problem is that the default configuration for running an application in "production" mode makes some assumptions about deployment -- primarily that you're using another webserver (eg. nginx, apache) for serving static assets. You're getting the file not found errors because by default Rails will not serve static assets in production mode
If you're trying to use WEBrick to duplicate a "production" environment, it needs to be configured to serve static assets. You can simply flip the boolean in your production.rb
environments/production.rb
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false
Once you make that change and restart the server, you'll be serving the assets you precompiled using WEBrick which while inefficient, will certainly give you an idea about what it's like in production.
Routing error, go to your routes.rb file and add
resources :users
Now when you run 'rake routes' from terminal you will see the relevant routes you require to navigate this model.

Resources