When I try my page i.e, localhost:3000/home - it shows this error.
This is the error thrown in the console:
ActionController::RoutingError (No route matches [GET] "/home"):
web-console (2.0.0.beta3) lib/action_dispatch/debug_exceptions.rb:22:in `middleware_call'
web-console (2.0.0.beta3) lib/action_dispatch/debug_exceptions.rb:13:in `call'
actionpack (4.2.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.2) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.2) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.2) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.2) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.2) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
I think there is some problem with the railties. But I am not sure what it is?
content of my routes.rb :
Rails.application.routes.draw do
get 'static_pages/home'
get 'static_pages/help'
end
You should define your route like this:
get 'home' => 'static_pages#home'
or:
root 'static_pages#home'
If you want to make it root path for your application.
Related
In our app we are using modules to organize some controllers. Here's what the directory structure looks like:
app/
controllers/
admin/
products/
reviews_controller.rb
orders/
line_items_controller.rb
products_controller.rb
orders_controller.rb
This works fine in development but is failing on our AWS server with the below error:
{"method":"GET","path":"/api/","format":"html","controller":"ApplicationController","action":"main","status":200,"duration":5.03,"view":0.15,"db":1.46,"#timestamp":"2019-02-28T16:21:08Z","process_id":36,"ip":"10.41.143.0","owner_id":null,"owner_type":null,"params":{}}
ActionController::RoutingError (uninitialized constant Admin::Products::ProductsController):
activesupport (4.2.10) lib/active_support/inflector/methods.rb:263:in `const_get'
activesupport (4.2.10) lib/active_support/inflector/methods.rb:263:in `block in constantize'
activesupport (4.2.10) lib/active_support/inflector/methods.rb:259:in `each'
activesupport (4.2.10) lib/active_support/inflector/methods.rb:259:in `inject'
activesupport (4.2.10) lib/active_support/inflector/methods.rb:259:in `constantize'
actionpack (4.2.10) lib/action_dispatch/routing/route_set.rb:70:in `controller_reference'
actionpack (4.2.10) lib/action_dispatch/routing/route_set.rb:60:in `controller'
actionpack (4.2.10) lib/action_dispatch/routing/route_set.rb:39:in `serve'
actionpack (4.2.10) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.10) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.10) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.10) lib/action_dispatch/routing/route_set.rb:817:in `call'
rack (1.6.10) lib/rack/etag.rb:24:in `call'
rack (1.6.10) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.10) lib/rack/head.rb:13:in `call'
actionpack (4.2.10) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.10) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.10) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.10) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.10) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.10) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.10) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
actionpack (4.2.10) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.10) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
activesupport (4.2.10) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
activesupport (4.2.10) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.10) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.10) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.10) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.2.10) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
rack-cors (1.0.2) lib/rack/cors.rb:97:in `call'
lograge (0.10.0) lib/lograge/rails_ext/rack/logger.rb:15:in `call_app'
railties (4.2.10) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.10) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.10) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.10) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.10) lib/rails/rack/logger.rb:20:in `call'
request_store (1.4.1) lib/request_store/middleware.rb:19:in `call'
actionpack (4.2.10) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.10) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.10) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.10) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
actionpack (4.2.10) lib/action_dispatch/middleware/static.rb:120:in `call'
rack (1.6.10) lib/rack/sendfile.rb:113:in `call'
ddtrace (0.8.0) lib/ddtrace/contrib/rack/middlewares.rb:89:in `call'
sentry-raven (2.7.4) lib/raven/integrations/rack.rb:51:in `call'
railties (4.2.10) lib/rails/engine.rb:518:in `call'
railties (4.2.10) lib/rails/application.rb:165:in `call'
rack (1.6.10) lib/rack/urlmap.rb:66:in `block in call'
rack (1.6.10) lib/rack/urlmap.rb:50:in `each'
rack (1.6.10) lib/rack/urlmap.rb:50:in `call'
puma (3.12.0) lib/puma/configuration.rb:225:in `call'
puma (3.12.0) lib/puma/server.rb:658:in `handle_request'
puma (3.12.0) lib/puma/server.rb:472:in `process_client'
puma (3.12.0) lib/puma/server.rb:332:in `block in run'
puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'
namespace :admin, shallow: true do
resources :products, module: 'products' do
resources :reviews
end
resources :orders, module: 'orders' do
resources :line_items
end
end
I'm not sure why it's looking for Admin::Products::ProductsController, because the products controller is under /app/controllers/admin/, not app/controllers/admin/products/.
Would really appreciate some help with this. I'm having trouble understanding why this is only occurring in production.
rake routes | grep 'products'
This is as much as I can share at the moment:
admin_products GET /admin/products(.:format) admin/products/products#index
POST /admin/products(.:format) admin/products/products#create
new_admin_products GET /admin/products/new(.:format) admin/products/products#new
edit_admin_products GET /admin/products/:id/edit(.:format) admin/products/products#edit
admin_product GET /admin/products/:id(.:format) admin/products/products#show
PATCH /admin/products/:id(.:format) admin/products/products#update
PUT /admin/products/:id(.:format) admin/products/products#update
DELETE /admin/products/:id(.:format) admin/products/products#destroy
The issue is that you are defining your module on the resources :products. You should define your module on the resources :reviews like this:
resources :products do
resources :reviews, module: 'products'
end
When you give a route a module, it will look inside ModuleName::ControllerName for the action(s).
I have no idea what mistake I've made this is so basic:
Localhost:3000 works as my root, but if I put localhost:3000/help I get the following error:
Started GET "/help" for 127.0.0.1 at 2016-02-09 17:11:37 -0500
ActionController::RoutingError (No route matches [GET] "/help"):
web-console (2.0.0.beta3) lib/action_dispatch/debug_exceptions.rb:22:in `middleware_call'
web-console (2.0.0.beta3) lib/action_dispatch/debug_exceptions.rb:13:in `call'
actionpack (4.2.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.2) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.2) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.2) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.2) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.2) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
actionpack (4.2.2) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
railties (4.2.2) lib/rails/engine.rb:518:in `call'
railties (4.2.2) lib/rails/application.rb:164:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
rack (1.6.4) lib/rack/content_length.rb:15:in `call'
rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service'
/home/reed/.rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
/home/reed/.rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
/home/reed/.rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
Here is my routes.rb:
Rails.application.routes.draw do
root 'static_pages#home'
get 'static_pages/help'
get 'static_pages/about'
end
I have the file help.html.erb under views/static_pages, below are the file contents:
<% provide(:title, "Help") %>
<h1>StaticPages#help</h1>
<p>Find me in app/views/static_pages/help.html.erb</p
Here is my controller:
class StaticPagesController < ApplicationController
def home
end
def help
end
end
This is about as basic as a rails app gets. I don't know what I've done, but if you can see the typo or wherever I have made a mistake please let me know. Thanks
Your syntax is off a bit.
You have:
Rails.application.routes.draw do
root 'static_pages#home'
get 'static_pages/help'
get 'static_pages/about'
end
It should be:
Rails.application.routes.draw do
root 'static_pages#home'
get 'help' => 'static_pages#help'
get 'about' => 'static_pages#about'
end
You can see the relevant rails documentation on this at this link
I see this error many times in my Ruby on Rails log file. I don´t know where does it come from?
F, [2015-07-13T13:03:00.178740 #22638] FATAL -- :
ActionController::RoutingError (No route matches [GET] "/manager/html"):
actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
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 tagged'
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'
puma (2.10.1) lib/puma/configuration.rb:74:in `call'
puma (2.10.1) lib/puma/server.rb:490:in `handle_request'
puma (2.10.1) lib/puma/server.rb:361:in `process_client'
puma (2.10.1) lib/puma/server.rb:254:in `block in run'
puma (2.10.1) lib/puma/thread_pool.rb:96:in `call'
puma (2.10.1) lib/puma/thread_pool.rb:96:in `block in spawn_thread'
These errors represent lame attempts by hackers to exploit various
known vulnerabilities in other applications.
See more details about it here.
I´m checking my Ruby on Rails log files and I wonder why do I have request like this one (my app doesn´t have any request like this):
I, [2015-07-13T11:45:26.004933 #22638] INFO -- : Started GET "/Ringing.at.your.dorbell!" for 186.116.51.54 at 2015-07-13 11:45:26 +0000
F, [2015-07-13T11:45:26.005954 #22638] FATAL -- :
ActionController::RoutingError (No route matches [GET] "/Ringing.at.your.dorbell!"):
actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
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 tagged'
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'
puma (2.10.1) lib/puma/configuration.rb:74:in `call'
puma (2.10.1) lib/puma/server.rb:490:in `handle_request'
puma (2.10.1) lib/puma/server.rb:361:in `process_client'
puma (2.10.1) lib/puma/server.rb:254:in `block in run'
puma (2.10.1) lib/puma/thread_pool.rb:96:in `call'
puma (2.10.1) lib/puma/thread_pool.rb:96:in `block in spawn_thread'
This just looks like someone is poking your system with a script, or just poking to see if that URL exists. Have you double checked that you're serving up the proper 404 response?
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'