1

My Rails application name is Card. I have modified the routes and removed the index.html from public directory. Still I see The page you were looking for doesn't exist. when I visit my home page. Rake routes displays the root route correctly.

I am using Passenger with Apache.

root@emaillenin:/var/emaillenin/rails/card# cat config/routes.rb
Card::Application.routes.draw do
root :to => "home#index"
end
root@emaillenin:/var/emaillenin/rails/card# ls public/
404.html  422.html  500.html  favicon.ico  robots.txt
root@emaillenin:/var/emaillenin/rails/card# rake routes
root  / home#index
root@emaillenin:/var/emaillenin/rails/card# ls app/controllers/
application_controller.rb  home_controller.rb
root@emaillenin:/var/emaillenin/rails/card# cat app/controllers/home_controller.rb
class HomeController < ApplicationController
  def index
  end
end
root@emaillenin:/var/emaillenin/rails/card# cat app/views/home/index.html.erb
<h1>Home#index</h1>
<p>Find me in app/views/home/index.html.erb</p>
<h1>Hello, Rails!</h1>
root@emaillenin:/var/emaillenin/rails/card# bundle exec rake assets:precompile
/usr/local/rvm/rubies/ruby-2.0.0-p195/bin/ruby /usr/local/rvm/gems/ruby-2.0.0-p195@global/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
root@emaillenin:/var/emaillenin/rails/card# cat config/environments/production.rb | grep config.assets.compile
  config.assets.compile = true
root@emaillenin:/var/emaillenin/rails/card#

This is what I see in the Apache error log: ActionController::RoutingError (No route matches [GET] "/"):

When I do rails server and access my homepage via 3000 port, I see an error page - http://pastebin.com/1eEU3egt

Even after executing bundle exec rake assets:precompile I see the same error page.

Even after changing config.assets.compile to true results in the same error.

Any way to crack down this issue?

Raj
  • 22,346
  • 14
  • 99
  • 142

1 Answers1

2

From another SO question :

By default Rails assumes that you have your files precompiled in the production environment, if you want use live compiling (compile your assets during runtime) in production you must set the config.assets.compile to true.

# config/environments/production.rb
...
config.assets.compile = true
...

You can use this option to fallback to Sprockets when you are using precompiled assets but there are any missing precompiled files.

If config.assets.compile option is set to false and there are missing precompiled files you will get an "AssetNoPrecompiledError" indicating the name of the missing file.

Community
  • 1
  • 1
Justin D.
  • 4,946
  • 5
  • 36
  • 69