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
Related
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 use Airbrake to notify me about errors in my Spree Commerce shop. Now that I want to use the API of spree, I get the following error, when I try to post to http://localhost:3000/api/products to create a new product:
NoMethodError (undefined method `airbrake_request_data' for #<Spree::Api::V1::ProductsController:0x007f9fcdb81b58>):
activesupport (3.2.9) lib/active_support/core_ext/object/try.rb:36:in `try'
airbrake (3.1.11) lib/airbrake/rails/middleware.rb:46:in `request_data'
airbrake (3.1.11) lib/airbrake/rails/middleware.rb:39:in `notify_airbrake'
airbrake (3.1.11) lib/airbrake/rails/middleware.rb:15:in `rescue in call'
airbrake (3.1.11) lib/airbrake/rails/middleware.rb:12:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.9) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.9) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.9) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.9) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.9) 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.9) 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.9) lib/action_dispatch/middleware/static.rb:62:in `call'
airbrake (3.1.11) lib/airbrake/user_informer.rb:16:in `_call'
airbrake (3.1.11) lib/airbrake/user_informer.rb:12:in `call'
railties (3.2.9) lib/rails/engine.rb:479:in `call'
railties (3.2.9) lib/rails/application.rb:223:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.9) 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#system/gems/actionpack-3.2.9/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.4ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p392#system/gems/actionpack-3.2.9/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (16.6ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p392#system/gems/actionpack-3.2.9/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (55.2ms)
Obviously, there is an error in my call. But I want to know which error. And of course, Airbrake should also notify errors from the API. I configured Airbrake with Spree so:
Gemfile
gem "airbrake"
initializers/airbrake.rb
Airbrake.configure do |config|
config.api_key = 'XXXXXXXXXXXXXXXXXXX'
end
So, a simple setup. I'm using Spree 1-2-stable, and I have no idea where to start to solve this problem.
You're encountering this error because the Spree API extends ActionController::Metal instead of ActionController::Base.
The airbrake gem performs some logic shown here:
https://github.com/airbrake/airbrake/blob/68543097a8731cf1f3e717946bd5ed33e5edccad/lib/airbrake/rails.rb#L13
which includes methods in to ActionController::Base.
You have a few options on how to get around this:
Load the methods in to ActionController::Metal as well using a similar method to that shown in the airbrake gem
Load the methods in to Spree::Api::BaseController using a similar method
Decorate Spree::Api::BaseController to include the methods directly
That should get you going.
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.
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
Ive created a new page in the public/ folder called hello.html (for example).
But for some reason, whenever I try to access it I recieve a routing error.
The response my server gives is..
Started GET "/hello.html" for 127.0.0.1 at 2012-03-04 17:39:29 +0000
ActionController::RoutingError (No route matches [GET] "/hello.html"):
actionpack (3.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.2) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.2) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.2) 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.2) 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.2) lib/action_dispatch/middleware/static.rb:61:in `call'
railties (3.2.2) lib/rails/engine.rb:479:in `call'
railties (3.2.2) lib/rails/application.rb:220:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.2) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/Users/Keva161/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/Keva161/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/Keva161/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
Rendered /Users/Keva161/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.2/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (6.3ms)
I believe this is an issue with ActionController being over-zelous but have no idea on how to fix it.
Any ideas?
what ever you are doing. you are looking at the wrong stuff.
i just cloned your repo and ran the app:
~ curl "http://localhost:3000/hello.html"
<!DOCTYPE html>
<html>
<head>
<title>Greetings!</title>
<body>
</body>
<p>Hello World!</p>
</head>
</html>%
Rails doesn't require the extension. You should be able to get to your static page by simply going to /hello.