I create a new rails 4beta1 app (ruby 2.0) from scratch and when I launch de server in development mode it runs fine but when I try in production it doesn't.
I already try to run bundle exec rake assets:precompile RAILS_ENV=production and change the config.serve_static_assets to true in the config/environments/production file but I still got the error:
=> Booting WEBrick
=> Rails 4.0.0.beta1 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2013-04-03 11:53:46] INFO WEBrick 1.3.1
[2013-04-03 11:53:46] INFO ruby 2.0.0 (2013-02-24) [x86_64-darwin12.2.0]
[2013-04-03 11:53:46] INFO WEBrick::HTTPServer#start: pid=13848 port=3000
I, [2013-04-03T11:53:50.521162 #13848] INFO -- : Started GET "/" for 127.0.0.1 at 2013-04-03 11:53:50 +0100
F, [2013-04-03T11:53:50.695426 #13848] FATAL -- :
ActionController::RoutingError (No route matches [GET] "/"):
actionpack (4.0.0.beta1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (4.0.0.beta1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.0.beta1) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.0.beta1) lib/rails/rack/logger.rb:21:in `block in call'
activesupport (4.0.0.beta1) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.0.beta1) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.0.beta1) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.0.beta1) lib/rails/rack/logger.rb:21:in `call'
actionpack (4.0.0.beta1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.0.0.beta1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
actionpack (4.0.0.beta1) lib/action_dispatch/middleware/static.rb:64:in `call'
railties (4.0.0.beta1) lib/rails/engine.rb:510:in `call'
railties (4.0.0.beta1) lib/rails/application.rb:96:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
/Users/jbatista/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
/Users/jbatista/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
/Users/jbatista/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
Webpage error:
In Rails 4.0, for technical reasons the default Rails page doesn't work on production environment, this includes any server (like heroku). The good news is that the error will go away when you start add controllers, set routes, etc...
Just start development and you'll be fine.
also looks like you need to define the root route in config/routes.rb
something like
MyApp::Application.routes.draw do
root :to => "MyApp#index"
end
where MyApp refers to your applications name.
In config/environments/production.rb serve_static_assets should be false because in production their server will handle them.
config.serve_static_assets = false
Moreover, you should not use WEBrick in production, it should only be used in development. Go for thin for example instead.
Basically, add gem 'thin' to our Gemfile.
Related
I randomly see a No route matches [GET] "/" error in the logs of an app. Here is the output.
[LG53P2]2016-10-25 02:46:20 +0000 severity=FATAL, ActionController::RoutingError (No route matches [GET] "/"): FATAL
[LG53P2] actionpack (4.2.7.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
[LG53P2] actionpack (4.2.7.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
[LG53P2] railties (4.2.7.1) lib/rails/rack/logger.rb:38:in `call_app'
[LG53P2] railties (4.2.7.1) lib/rails/rack/logger.rb:22:in `call'
[LG53P2] actionpack (4.2.7.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
[LG53P2] rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
[LG53P2] rack (1.6.4) lib/rack/runtime.rb:18:in `call'
[LG53P2] activesupport (4.2.7.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
[LG53P2] actionpack (4.2.7.1) lib/action_dispatch/middleware/static.rb:120:in `call'
[LG53P2] rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
[LG53P2] actionpack (4.2.7.1) lib/action_dispatch/middleware/ssl.rb:24:in `call'
[LG53P2] skylight (0.10.5) lib/skylight/middleware.rb:61:in `call'
[LG53P2] railties (4.2.7.1) lib/rails/engine.rb:518:in `call'
[LG53P2] railties (4.2.7.1) lib/rails/application.rb:165:in `call'
[LG53P2] puma (3.4.0) lib/puma/configuration.rb:224:in `call'
[LG53P2] puma (3.4.0) lib/puma/server.rb:569:in `handle_request'
[LG53P2] puma (3.4.0) lib/puma/server.rb:406:in `process_client'
[LG53P2] puma (3.4.0) lib/puma/server.rb:271:in `block in run'
[LG53P2] puma (3.4.0) lib/puma/thread_pool.rb:114:in `call'
[LG53P2] puma (3.4.0) lib/puma/thread_pool.rb:114:in `block in spawn_thread'
The app is private and used by a really small number of people and none of the users have experienced this error ( not able to access the root_path ). I never see it outside the logs. I assume this could be a bot doing a scan.
The routes.rbfile contains the right information:
constraints subdomain: "the_subdomain" do
scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do
root to: 'my_controller/static#home'
end
.... other routes
end
And the rake routes output seems normal:
root GET /(:locale)(.:format) my_controller/static#home
At this point the app is regularly used and this bug is just a glitch in the logs nothing more. But I think it worth asking!
Any idea about what can cause this error and how or if I can do something about it?
With the given informations nginx proxies all requests to the Rails app. If the host is accessed directly via IP-Address or custom DNS entries, the first app in line gets the request.
Because the root_path is restricted to a subdomain, the given routing error occours.
There are multiple solutions. First, restrict nginx to route only known subdomains to the Rails app. Second, add a route outside the constraint and log such requests with a special controller and action. Third, redirect unknown subdomains to a special site.
I have taken an existing site. Integrated a CMS (Comfortable Mexican Sofa). Then installed Redactor. Threw Redactor I have the ability to add content and display it on localhost:3000. I also have the ability to upload Files. I run into a problem using its insert image function in the content box.
My server log:
Started POST "/admin/sites/2/pages/2/null?ajax=1" for 127.0.0.1 at 2015-09-22 01:26:44 -0400
ActionController::RoutingError (No route matches [POST] "/admin/sites/2/pages/2/null"):
actionpack (4.0.3) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (4.0.3) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.3) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.3) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.0.3) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.3) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.3) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.3) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.0.3) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.0.3) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.3) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.0.3) lib/rails/engine.rb:511:in `call'
railties (4.0.3) lib/rails/application.rb:97:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
/Users/bam/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
/Users/bam/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
/Users/bam/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
My Gemfile's relevent Gems (I did not add imagemagick to the Gemfile although I have installed it).
ruby '2.0.0'
gem 'rails', '4.0.3'
gem "paperclip", "~> 4.3.0"
gem 'comfortable_mexican_sofa', '~> 1.12.0'
gem 'kaminari'
config/environments/development
# Per https://github.com/thoughtbot/paperclip
Paperclip.options[:command_path] = "/usr/bin/"
routes
comfy_route :cms_admin, :path => '/admin'
# Make sure this routeset is defined last
comfy_route :cms, :path => '/', :sitemap => false
config/initializers/paperclip.rb
Paperclip.options[:command_path] = "/usr/bin/"
When I file upload and it is successful this is the first two lines of the server log where the difference occurs is on line 2.
Started POST "/admin/sites/2/files?ajax=true" for 127.0.0.1 at 2015-09-22 01:48:10 -0400
Processing by Comfy::Admin::Cms::FilesController#create as HTML
Feel Free to checkout out the repo I was not sure how do demonstrate the files that Redactor added. https://github.com/jpbamberg1993/aqqaluk the branch it "redactor".
Do not hesitate to critique this post it is my first one.
Thank You
Turns out that the new version of Comfortable Mexican Sofa comes with redactor. Based on our Ruby version it was defaulting to the older version. Upgrading the gemset solved the problem.
https://github.com/comfy/comfortable-mexican-sofa/tree/v1.12.6
Another alternative that was presented to me was to "You can upload the image in the Files section of the admin, then refer to the image in your default page editor. After you upload an image, CMS adds an “uploaded files” module to the right of your editor where you can copy-and-paste image URLs to create <image> tags." Ed Toro
I trying to run for app on server and log file give me an error
You may have mistyped the address or the page may have moved.
and in log file
[2014-03-12T09:50:22.614788 #1647] INFO -- : Started GET "/" for
84.38.185.44 at 2014-03-12 09:50:22 +0000
F, [2014-03-12T09:50:22.771502 #1647] FATAL -- :
ActionController::RoutingError (No route matches [GET] "/"):
actionpack (4.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:21:in call'
actionpack (4.0.2) lib/action_dispatch/middleware/show_exceptions.rb:30:incall'
railties (4.0.2) lib/rails/rack/logger.rb:38:in call_app'
railties (4.0.2) lib/rails/rack/logger.rb:20:inblock in call'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in block in tagged'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:25:intagged'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in tagged'
railties (4.0.2) lib/rails/rack/logger.rb:20:incall'
actionpack (4.0.2) lib/action_dispatch/middleware/request_id.rb:21:in call'
rack (1.5.2) lib/rack/methodoverride.rb:21:incall'
rack (1.5.2) lib/rack/runtime.rb:17:in call'
activesupport (4.0.2) lib/active_support/cache/strategy/local_cache.rb:83:incall'
rack (1.5.2) lib/rack/sendfile.rb:112:in call'
railties (4.0.2) lib/rails/engine.rb:511:incall'
railties (4.0.2) lib/rails/application.rb:97:in call'
unicorn (4.7.0) lib/unicorn/http_server.rb:580:inprocess_client'
unicorn (4.7.0) lib/unicorn/http_server.rb:660:in worker_loop'
unicorn (4.7.0) lib/unicorn/http_server.rb:527:inspawn_missing_workers'
unicorn (4.7.0) lib/unicorn/http_server.rb:153:in start'
unicorn (4.7.0) bin/unicorn:126:in'
/usr/local/rvm/gems/ruby-2.0.0-p353/bin/unicorn:23:in load'
/usr/local/rvm/gems/ruby-2.0.0-p353/bin/unicorn:23:in'
/usr/local/rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in
eval'
/usr/local/rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in
'
that can i do with it?
Seems that the root route is not defined. Open your route.rb ad check if there's something like this:
root :to => "controller#index"
Could you try to add the following line (posts for example)?
# config/routes.rb
root to: 'posts#index'
I'm just starting to use Ruby on Rails and I am going through a tutorial to get started. I have everything working for testing, so I can use a rails server command in the directory to make it show the basic "Welcome aboard" page that I want to see; however, when I change this to rails server -e production I suddenly only see the "The page you were looking for doesn't exist." page. When this happens, the command prompt shows:
[2013-08-07 19:54:26] INFO WEBrick 1.3.1
[2013-08-07 19:54:26] INFO ruby 1.9.3 (2013-06-27) [i386-mingw32]
[2013-08-07 19:54:26] INFO WEBrick::HTTPServer#start: pid=12664 port=3000
I, [2013-08-07T19:54:26.515238 #12664] INFO -- : Started GET "/" for 127.0.0.1
at 2013-08-07 19:54:26 -0700
F, [2013-08-07T19:54:26.752394 #12664] FATAL -- :
ActionController::RoutingError (No route matches [GET] "/"):
actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `c
all'
actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `ca
ll'
railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tag
ged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `
call'
railties (4.0.0) lib/rails/engine.rb:511:in `call'
railties (4.0.0) lib/rails/application.rb:97:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
C:/Ruby193/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
C:/Ruby193/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
C:/Ruby193/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
This may seem very similar to a number of other questions, but I have tried a number of solutions that have all failed. Thank you for any possible help.
Indeed, this is the default behaviour for an application that has no routes.
The "Welcome aboard" page is just an introduction for developers and is only shown in the development environment.
I have been doing the Treehouse exercise on building a Rails app to do status updates. I was able to go to 0.0.0.0:3000 but I am still unable to go to 0.0.0.0:3000/statuses. The following is my Terminal output:
Started GET "/statuses" for 127.0.0.1 at 2013-04-22 02:32:07 -0700
ActionController::RoutingError (No route matches [GET] "/statuses"): actionpack (3.2.12) lib/action_dispatch/middleware/debug_exceptions.rb:21:in call' actionpack (3.2.12) lib/action_dispatch/middleware/show_exceptions.rb:56:incall' railties (3.2.12) lib/rails/rack/logger.rb:32:in call_app' railties (3.2.12) lib/rails/rack/logger.rb:16:inblock in call' activesupport (3.2.12) lib/active_support/tagged_logging.rb:22:in tagged' railties (3.2.12) lib/rails/rack/logger.rb:16:incall' actionpack (3.2.12) lib/action_dispatch/middleware/request_id.rb:22:in call' rack (1.4.5) lib/rack/methodoverride.rb:21:incall' rack (1.4.5) lib/rack/runtime.rb:17:in call' activesupport (3.2.12) lib/active_support/cache/strategy/local_cache.rb:72:incall' rack (1.4.5) lib/rack/lock.rb:15:in call' actionpack (3.2.12) lib/action_dispatch/middleware/static.rb:62:incall' railties (3.2.12) lib/rails/engine.rb:479:in call' railties (3.2.12) lib/rails/application.rb:223:incall' rack (1.4.5) lib/rack/content_length.rb:14:in call' railties (3.2.12) lib/rails/rack/log_tailer.rb:17:incall' rack (1.4.5) lib/rack/handler/webrick.rb:59:in service' /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/httpserver.rb:138:inservice' /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/httpserver.rb:94:in run' /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/server.rb:191:inblock in start_thread'
Rendered /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.12/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (20.0ms)
When I go to 0.0.0.0:3000/statuses, my browser says:
0.0.0.0:3000/stauses:
Routing Error
No route matches [GET] "/statuses" Try running rake routes for more information on available routes.
** I tried running rake routes and tried rake:db migrate and then typing in rails server but none of those worked. Any thoughts?
Add this to your routes.rb in the config folder.
resources :statuses
and make sure you have a controller named statuses_controller.rb and a view at views/statuses/index.html.erb
Add the following entry in the routes.rb file:
{ get "statuses" => 'statuses#index'}
This will work if you have statuses-controller.rb in app/controller folder and index.html.erb file in the app/views/statuses folder.