Static pages not working? - ruby-on-rails

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.

Related

Ruby on Rails: ActionController::RoutingError on VPS works fine in local

I run my rails server on port 80 on a VPS, usually the server is up for about 24 hours before I get an error:
I have done a fair few google searches and cannot seem to find the answer.
This isn't a problem when running on local, I had an error similar to this to do with the chkservd module, so maybe it is a similar issue this time?
Started GET "/whm-server-status" for 127.0.0.1 at 2013-11-13 16:10:01 -0600
ActionController::RoutingError (No route matches [GET] "/whm-server-status"):
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'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64: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'
/usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
Rendered /usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.4ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/routes/_route.html.erb (5.6ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/routes/_table.html.erb (1.5ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (56.0ms)

Ruby on Rails devise issues

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

Routing error with font-awesome assets in Rails 3

The font-awesome css file is located in app/assets/stylesheets/font-awesome.css and yet the error is:
ActionController::RoutingError (No route matches [GET] "/assets/stylesheets/font-awesome.css"):
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'
webrick (1.3.1) lib/webrick/httpserver.rb:138:in `service'
webrick (1.3.1) lib/webrick/httpserver.rb:94:in `run'
webrick (1.3.1) lib/webrick/server.rb:191:in `block in start_thread'
Based on another Github answer (https://github.com/seyhunak/twitter-bootstrap-rails/issues/535), fontawesome-webfont.woff is located in vendor/assets/font but the error is:
Started GET "/font/fontawesome-webfont.woff?v=3.2.1" for 127.0.0.1 at 2013-08-03 16:31:35 -0700
ActionController::RoutingError (No route matches [GET] "/font/fontawesome-webfont.woff"):
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'
webrick (1.3.1) lib/webrick/httpserver.rb:138:in `service'
webrick (1.3.1) lib/webrick/httpserver.rb:94:in `run'
webrick (1.3.1) lib/webrick/server.rb:191:in `block in start_thread'
I have tried pre-compiling the assets before running the app but that doesn't work either. Any ideas would be much appreciated!
This is the general guide to using font-awesome with Rails.
However I usually just use this gem which does it for you.

Airbrake and Spree commerce API: undefined method `airbrake_request_data`

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.

Routing Error for assets Rails 3.2.8 on Upgrading Rails 3.1

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

Resources