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.
Related
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 have been trying to figure this out for way too long and i am hoping for some help here. I am new to Ruby and downloaded devise gem but when i try to run the sign up page it is giving me this error in my terminal:
Started GET "/users/sign_up" for 127.0.0.1 at 2013-09-11 17:52:28 -0700
ActionController::RoutingError (No route matches [GET] "/users/sign_up"):
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:in `call'
railties (3.2.12) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.12) lib/rails/rack/logger.rb:16:in `block 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:in `call'
actionpack (3.2.12) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.12) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
actionpack (3.2.12) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.12) lib/rails/engine.rb:479:in `call'
railties (3.2.12) lib/rails/application.rb:223:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.12) lib/rails/rack/log_tailer.rb:17:in `call'
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:in `service'
/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:in `block in start_thread'
Rendered /usr/local/rvm/gems/ruby-1.9.3-p392#rails3tutorial2ndEd/gems/actionpack-3.2.12/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (3.0ms)
I imagine this means i do not have a route for the sign up page. How do i set that up. I have looked online and tried almost everything and nothing seems to work.
I would first make sure Devise is set up properly, per the instructions here... https://github.com/plataformatec/devise
Specifically (after getting the Devise gem)...
rails generate devise:install
followed by...
rails generate devise MODEL
Where MODEL is often User.
After that your routes should just work assuming your links are correct. The sign up link alias is...
new_user_registration_path
Your routes.rb should have something like the following in it if it's set up properly...
devise_for :users
In your routes.rb
devise_for :users
maybe try running
rails g devise User
Hopefully you have already run
rails g devise:install
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 occasionally see such errors in the log file, how do I handle this.
Started GET "/w00tw00t.at.ISC.SANS.Win32:)" for 69.25.37.166 at 2013-01-02 00:06:05 +0000
ActionController::RoutingError (No route matches [GET] "/w00tw00t.at.ISC.SANS.Win32:)"):
actionpack (3.2.6) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (3.2.6) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.6) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.6) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.6) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.6) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
Try something like this:
routes.rb
match '*a', :to => 'errors#routingIssue'
create error controller - errors_controller.rb
class ErrorsController < ApplicationController
def routingIssue
render_404
end
end
Its really frustrating to see the routing errors for stylesheets, images when I upgrade to 3.2.8 from 3.1.1 Rails. Tried the "bundle exec rails server" command and also tried a adding the gems in the file one by one, did not work too :(
ActionController::RoutingError (No route matches [GET] "/stylesheets/application.css"):
actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.8) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.8) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.8) lib/rails/engine.rb:479:in `call'
railties (3.2.8) lib/rails/application.rb:223:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.8) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
When linking to assets in rails, always use asset_path, asset_url, or one of the helper functions that call these in turn (image_path, image_url, javascript_include_tag, stylesheet_link_tag).
In your case, it looks like you hardcoded /stylesheets/application.css in your application layout. Simple change that code to something like
<%= stylesheet_link_tag :application %>
and it should correctly point to /assets/application.css for development, and /assets/application-<sha1 hash>.css in production (when assets are compiled).
Also, if you have the assets compiled locally (if you have anything in public/assets this is the case. You may want to rm -rf public/assets if you're developing locally), then you need the following line in your config/application.rb:
config.serve_static_assets = true