Trying to write a "points" system in my Rails 3 app - ruby-on-rails-3

Rails 3.2.3
I'm trying to add a "points" functionality to my Rails app. The idea is pretty straight forward, if you click UP your points will increase by 1. if you click DOWN your points will decrease by 1. But for some reason the points do not change and each new links I create the points increase by 10.
I have the points defaulting to 0 in my migration file (but they never show zero)
t.column :points, :integer, :default => 0`
here is part of my view code
<td>
<%= link_to "Up",
:url => { :action => 'modify_points',
:id => link.id,
:by => 1 },
:remote => true,
:update => "link" + link.id.to_s %>
</td>
<td>
<%= link_to "Down",
:url => { :action => 'modify_points',
:id => link.id,
:by => -1 },
:remote => true,
:update => "link" + link.id.to_s %>
</td>
<td>
<b> <%= link.description %> </b>
(<%= if link.url =~ /:\/\/([^\/]*)/ then $1 else "wrong URL" end %>) <br/>
<span id="link"><%= link.id.to_s %><%= link.points %> </span>
points posted <%= time_ago_in_words link.created_at %> ago
</td>
and here is my modify_points method in my links_controller.rb:
def modify_points
#link = Link.find(params[:id])
#link.update_attribute :points, #link.points + params[:by].to_i if params[:by] =~ /[+|-]?1/
render_text #link.points
end
right now, my first submitted link has 10 points, my 2nd link has 20 points, my 3rd link has 30 points ... etc.... etc... and the UP & DOWN links do nothing. Why am I not seeing the default point value of 0? Is my regex code in the modify_points method causing these errors?
** EDIT: HERE IS MY RAILS SERVER LOG WHEN PRESSING the UP LINK **
Processing by LinksController#submissions as HTML
(0.1ms) SELECT COUNT(*) FROM "links"
Link Load (0.3ms) SELECT "links".* FROM "links" LIMIT 20 OFFSET 0
Rendered links/submissions.html.erb within layouts/application (145.9ms)
Completed 200 OK in 435ms (Views: 316.5ms | ActiveRecord: 9.4ms)
Started GET "/assets/links.css?body=1" for 127.0.0.1 at 2012-06-11 10:08:49 -0700
Served asset /links.css - 304 Not Modified (8ms)
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2012-06-11 10:08:51
-0700
Served asset /application.js - 304 Not Modified (9ms)
Started GET "/assets/defaults.js" for 127.0.0.1 at 2012-06-11 10:08:51 -0700
Served asset /defaults.js - 404 Not Found (3ms)
ActionController::RoutingError (No route matches [GET] "/assets/defaults.js"):
actionpack (3.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.3) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.3) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.3) 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.3) 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.3) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.3) lib/rails/engine.rb:479:in `call'
railties (3.2.3) lib/rails/application.rb:220:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.3) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/Users/accraze/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/Users/accraze/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/Users/accraze/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
Rendered /Users/accraze/.rvm/gems/ruby-1.9.2-p290#rails3tutorial/gems/actionpack-3.2.3/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.8ms)
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2012-06-11 10:08:51 -0700
Served asset /application.css - 304 Not Modified (4ms)
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2012-06-11 10:08:51 -0700
Served asset /jquery.js - 304 Not Modified (4ms)
Started GET "/assets/scaffolds.css?body=1" for 127.0.0.1 at 2012-06-11 10:08:51-0700
Served asset /scaffolds.css - 304 Not Modified (3ms)
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2012-06-11 10:08:51-0700
Served asset /jquery_ujs.js - 304 Not Modified (3ms)
Started GET "/assets/links.js?body=1" for 127.0.0.1 at 2012-06-11 10:08:51 -0700
Served asset /links.js - 304 Not Modified (2ms)
Started GET "/?remote=true&update=link4&url%5Baction%5D=modify_points&url%5Bby%5D=1&url%5Bid%5D=4" for 127.0.0.1 at 2012-06-11 10:08:54 -0700
Processing by LinksController#submissions as HTML
Parameters: {"remote"=>"true", "update"=>"link4", "url"=>{"action"=>"modify_points", "by"=>"1", "id"=>"4"}}
(0.2ms) SELECT COUNT(*) FROM "links"
Link Load (0.2ms) SELECT "links".* FROM "links" LIMIT 20 OFFSET 0
Rendered links/submissions.html.erb within layouts/application (14.7ms)
Completed 200 OK in 21ms (Views: 20.4ms | ActiveRecord: 0.4ms)
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2012-06-11 10:08:54 -0700
Served asset /application.css - 304 Not Modified (0ms)
Started GET "/assets/scaffolds.css?body=1" for 127.0.0.1 at 2012-06-11 10:08:54-0700
Served asset /scaffolds.css - 304 Not Modified (0ms)
Started GET "/assets/links.css?body=1" for 127.0.0.1 at 2012-06-11 10:08:54 -0700
Served asset /links.css - 304 Not Modified (0ms)
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2012-06-11 10:08:54-0700
Served asset /application.js - 304 Not Modified (0ms)
Started GET "/assets/links.js?body=1" for 127.0.0.1 at 2012-06-11 10:08:54 -0700
Served asset /links.js - 304 Not Modified (0ms)
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2012-06-11 10:08:54 -0700
Served asset /jquery.js - 304 Not Modified (0ms)
Started GET "/assets/defaults.js" for 127.0.0.1 at 2012-06-11 10:08:54 -0700
Served asset /defaults.js - 404 Not Found (4ms)
ActionController::RoutingError (No route matches [GET] "/assets/defaults.js"):
actionpack (3.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.3) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.3) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.3) 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.3) 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.3) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.3) lib/rails/engine.rb:479:in `call'
railties (3.2.3) lib/rails/application.rb:220:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.3) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/Users/accraze/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/Users/accraze/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/Users/accraze/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
Rendered /Users/accraze/.rvm/gems/ruby-1.9.2-p290#rails3tutorial/gems/actionpa
ck-3.2.3/lib/action_dispatch/middleware/templates/rescues/routing_error.erb with
in rescues/layout (0.8ms)
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2012-06-11 10:08:55-
0700
Served asset /jquery_ujs.js - 304 Not Modified (0ms)

Well, your link doesn't do what you want - as you can see from the log, here:
Processing by LinksController#submissions as HTML
Started GET "/?remote=true&update=link4&url%5Baction%5D=modify_points&url%5Bby%5D=1&url%5Bid%5D=4" for 127.0.0.1 at 2012-06-11 10:08:54 -0700
Processing by LinksController#submissions as HTML
Parameters: {"remote"=>"true", "update"=>"link4", "url"=>{"action"=>"modify_points", "by"=>"1", "id"=>"4"}}
It's treating your :url as a normal parameter, and is passing it to LinksController#submissions. You should probably be using a route-based helper? Something like this, depending on what your routes look like:
<%= link_to('UP', link_modify_points_path(link, :by => 1), :remote => true) %>

Related

ActionController::RoutingError (No route matches [GET]

I am doing a GET request via postman to access a company through
http://localhost:3000/api/v1/company /1
Just added a method in the companies controller as this:
module Api
module V1
class CompaniesController < ApplicationController
def index
#companies = Company.order('created_at DESC');
render json: { status: 'SUCCESS', message:'Loaded companies', data:#companies }, status: :ok
end
def show
#companies = Company.find(params[:id])
render json: { status: 'SUCCESS', message:'Loaded company', data:#companies }, status: :ok
end
end
end
end
My logs look like this:
=> Booting Puma
=> Rails 5.1.3 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.10.0 (ruby 2.3.1-p112), codename: Russell's Teapot
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
Started GET "/api/v1/companies" for 127.0.0.1 at 2017-08-28 08:20:43 +0300
(1.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
Processing by Api::V1::CompaniesController#index as */*
Company Load (1.2ms) SELECT "companies".* FROM "companies" ORDER BY created_at DESC LIMIT $1 [["LIMIT", 11]]
Company Load (0.6ms) SELECT "companies".* FROM "companies" ORDER BY created_at DESC LIMIT $1 [["LIMIT", 11]]
Completed 500 Internal Server Error in 143ms (ActiveRecord: 0.0ms)
Company Load (0.6ms) SELECT "companies".* FROM "companies" ORDER BY created_at DESC LIMIT $1 [["LIMIT", 11]]
NameError (undefined local variable or method `companies' for #<Api::V1::CompaniesController:0x000000043ff3c8>
Did you mean? #companies):
app/controllers/api/v1/companies_controller.rb:6:in `index'
Company Load (0.6ms) SELECT "companies".* FROM "companies" ORDER BY created_at DESC LIMIT $1 [["LIMIT", 11]]
Started GET "/api/v1/companies" for 127.0.0.1 at 2017-08-28 08:21:04 +0300
Processing by Api::V1::CompaniesController#index as */*
Company Load (0.7ms) SELECT "companies".* FROM "companies" ORDER BY created_at DESC
Completed 200 OK in 23ms (Views: 19.5ms | ActiveRecord: 0.7ms)
Started GET "/api/v1/companies%20/1" for 127.0.0.1 at 2017-08-28 08:33:41 +0300
ActionController::RoutingError (No route matches [GET] "/api/v1/companies%20/1"):
actionpack (5.1.3) lib/action_dispatch/middleware/debug_exceptions.rb:63:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.3) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.3) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.3) lib/rails/rack/logger.rb:24:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.3) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.3) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.3) lib/rack/sendfile.rb:111:in `call'
rack-cors (1.0.1) lib/rack/cors.rb:93:in `call'
railties (5.1.3) lib/rails/engine.rb:522:in `call'
puma (3.10.0) lib/puma/configuration.rb:225:in `call'
puma (3.10.0) lib/puma/server.rb:605:in `handle_request'
puma (3.10.0) lib/puma/server.rb:437:in `process_client'
puma (3.10.0) lib/puma/server.rb:301:in `block in run'
puma (3.10.0) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
Started GET "/api/v1/companies%20/1" for 127.0.0.1 at 2017-08-28 08:34:46 +0300
ActionController::RoutingError (No route matches [GET] "/api/v1/companies%20/1"):
actionpack (5.1.3) lib/action_dispatch/middleware/debug_exceptions.rb:63:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.3) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.3) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.3) lib/rails/rack/logger.rb:24:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.3) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.3) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.3) lib/rack/sendfile.rb:111:in `call'
rack-cors (1.0.1) lib/rack/cors.rb:93:in `call'
railties (5.1.3) lib/rails/engine.rb:522:in `call'
puma (3.10.0) lib/puma/configuration.rb:225:in `call'
puma (3.10.0) lib/puma/server.rb:605:in `handle_request'
puma (3.10.0) lib/puma/server.rb:437:in `process_client'
puma (3.10.0) lib/puma/server.rb:301:in `block in run'
puma (3.10.0) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
Started GET "/api/v1/companies%20/1" for 127.0.0.1 at 2017-08-28 08:35:53 +0300
ActionController::RoutingError (No route matches [GET] "/api/v1/companies%20/1"):
actionpack (5.1.3) lib/action_dispatch/middleware/debug_exceptions.rb:63:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.3) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.3) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.3) lib/rails/rack/logger.rb:24:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.3) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.3) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.3) lib/rack/sendfile.rb:111:in `call'
rack-cors (1.0.1) lib/rack/cors.rb:93:in `call'
railties (5.1.3) lib/rails/engine.rb:522:in `call'
puma (3.10.0) lib/puma/configuration.rb:225:in `call'
puma (3.10.0) lib/puma/server.rb:605:in `handle_request'
puma (3.10.0) lib/puma/server.rb:437:in `process_client'
puma (3.10.0) lib/puma/server.rb:301:in `block in run'
puma (3.10.0) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
Started GET "/api/v1/company%20/1" for 127.0.0.1 at 2017-08-28 08:35:58 +0300
ActionController::RoutingError (No route matches [GET] "/api/v1/company%20/1"):
actionpack (5.1.3) lib/action_dispatch/middleware/debug_exceptions.rb:63:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.3) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.3) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.3) lib/rails/rack/logger.rb:24:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.3) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.3) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.3) lib/rack/sendfile.rb:111:in `call'
rack-cors (1.0.1) lib/rack/cors.rb:93:in `call'
railties (5.1.3) lib/rails/engine.rb:522:in `call'
puma (3.10.0) lib/puma/configuration.rb:225:in `call'
puma (3.10.0) lib/puma/server.rb:605:in `handle_request'
puma (3.10.0) lib/puma/server.rb:437:in `process_client'
puma (3.10.0) lib/puma/server.rb:301:in `block in run'
puma (3.10.0) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
Started GET "/api/v1/company%20/1" for 127.0.0.1 at 2017-08-28 08:36:25 +0300
ActionController::RoutingError (No route matches [GET] "/api/v1/company%20/1"):
actionpack (5.1.3) lib/action_dispatch/middleware/debug_exceptions.rb:63:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.3) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.3) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.3) lib/rails/rack/logger.rb:24:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.3) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.3) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.3) lib/rack/sendfile.rb:111:in `call'
rack-cors (1.0.1) lib/rack/cors.rb:93:in `call'
railties (5.1.3) lib/rails/engine.rb:522:in `call'
puma (3.10.0) lib/puma/configuration.rb:225:in `call'
puma (3.10.0) lib/puma/server.rb:605:in `handle_request'
puma (3.10.0) lib/puma/server.rb:437:in `process_client'
puma (3.10.0) lib/puma/server.rb:301:in `block in run'
puma (3.10.0) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
Started GET "/api/v1/company%20/1" for 127.0.0.1 at 2017-08-28 08:36:37 +0300
ActionController::RoutingError (No route matches [GET] "/api/v1/company%20/1"):
actionpack (5.1.3) lib/action_dispatch/middleware/debug_exceptions.rb:63:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.3) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.3) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.3) lib/rails/rack/logger.rb:24:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.3) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.3) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.3) lib/rack/sendfile.rb:111:in `call'
rack-cors (1.0.1) lib/rack/cors.rb:93:in `call'
railties (5.1.3) lib/rails/engine.rb:522:in `call'
puma (3.10.0) lib/puma/configuration.rb:225:in `call'
puma (3.10.0) lib/puma/server.rb:605:in `handle_request'
puma (3.10.0) lib/puma/server.rb:437:in `process_client'
puma (3.10.0) lib/puma/server.rb:301:in `block in run'
puma (3.10.0) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
Started GET "/api/v1/company%20/1" for 127.0.0.1 at 2017-08-28 08:37:03 +0300
ActionController::RoutingError (No route matches [GET] "/api/v1/company%20/1"):
actionpack (5.1.3) lib/action_dispatch/middleware/debug_exceptions.rb:63:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.3) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.3) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.3) lib/rails/rack/logger.rb:24:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.3) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.3) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.3) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.3) lib/rack/sendfile.rb:111:in `call'
rack-cors (1.0.1) lib/rack/cors.rb:93:in `call'
railties (5.1.3) lib/rails/engine.rb:522:in `call'
puma (3.10.0) lib/puma/configuration.rb:225:in `call'
puma (3.10.0) lib/puma/server.rb:605:in `handle_request'
puma (3.10.0) lib/puma/server.rb:437:in `process_client'
puma (3.10.0) lib/puma/server.rb:301:in `block in run'
puma (3.10.0) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
ActionController::RoutingError (No route matches [GET]
"/api/v1/companies%20/1"):
Your route has a space after companies which resulted in that error. Make sure your route doesn't contain the space. It should look like
"/api/v1/companies/1"

Routing error in Rails4 passenger and apache

I am trying to deploy my Rails4 app locally(I just want to it run on my Mac). I use Passenger and Apache for deployment. After some configuration, my home page works fine. But when I click any links on my homepage or go to any other path, I got this error:
The page you were looking for doesn't exist.
So I added this line to my httpd.conf file in apache
RailsEnv development
And now I got this error:
No route matches [GET] "/Users/joey/Sites/index.html"
No route matches [POST] "/Users/joey/Sites/index.html" (If I make a post request)
My project directory is "/Users/joey/Sites/depot" and this is my httpd.conf file:
<VirtualHost *:80>
ServerName depot.joeyhu.info
DocumentRoot /Users/joey/Sites/depot/public/
RailsEnv development
<Directory /Users/joey/Sites/depot/public>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
LoadModule passenger_module /Users/joey/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/passenger-4.0.50/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /Users/joey/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/passenger-4.0.50
PassengerDefaultRuby /Users/joey/.rbenv/versions/2.1.0/bin/ruby
</IfModule>
This is my rails log(development.log and production.log basically show the same error):
I, [2014-09-12T10:31:17.300176 #41946] INFO -- : Started GET "/Users/joey/Sites/index.html" for 127.0.0.1 at 2014-09-12 10:31:17 -0700
F, [2014-09-12T10:31:17.300964 #41946] FATAL -- :
ActionController::RoutingError (No route matches [GET] "/Users/joey/Sites/index.html"):
actionpack (4.1.2) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (4.1.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.2) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.2) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.2) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.2) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.2) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.2) 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.1.2) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.2) lib/rails/engine.rb:514:in `call'
railties (4.1.2) lib/rails/application.rb:144:in `call'
passenger (4.0.50) lib/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
passenger (4.0.50) lib/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
passenger (4.0.50) lib/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
passenger (4.0.50) lib/phusion_passenger/request_handler.rb:455:in `block (3 levels) in start_threads'
Except the root_url, it loooks like whatever path I go to, it will make a get or post request to the URL "/Users/joey/Sites/index.html" which doesn't make sense. Can someone help me? Thanks!
I am using Rails 4.1.2.

ActionController::RoutingError when js => true

None of my tests have an error, except the one I'm adding with js => true. Oddly enough the test would pass if not for a routing error.
My test:
context 'Javascript', :js => true do
visit careers_path
page.should have_content("Your Recommendations")
end
I can actual puts page.body and see that the content is there, but it still comes up with this routing error. I notice that while running the actual server and it comes up with a GET request for the assets folder. I don't understand why or what is doing this, but it seems to be the cause of failure.
The errors:
While running rails s
Started GET "/assets/" for 127.0.0.1 at 2013-08-12 19:11:02 -0400
Served asset / - 404 Not Found (5ms)
While running rspec
Failure/Error: Unable to find matching line from backtrace
ActionController::RoutingError:
No route matches [GET] "/assets"
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/actionpack-3.2.14/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/actionpack-3.2.14/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.14/lib/rails/rack/logger.rb:32:in `call_app'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.14/lib/rails/rack/logger.rb:16:in `block in call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/activesupport-3.2.14/lib/active_support/tagged_logging.rb:22:in `tagged'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.14/lib/rails/rack/logger.rb:16:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/actionpack-3.2.14/lib/action_dispatch/middleware/request_id.rb:22:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/activesupport-3.2.14/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/actionpack-3.2.14/lib/action_dispatch/middleware/static.rb:63:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.14/lib/rails/engine.rb:484:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.14/lib/rails/application.rb:231:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/rack-1.4.5/lib/rack/builder.rb:134:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/rack-1.4.5/lib/rack/urlmap.rb:64:in `block in call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/rack-1.4.5/lib/rack/urlmap.rb:49:in `each'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/rack-1.4.5/lib/rack/urlmap.rb:49:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/capybara-2.1.0/lib/capybara/server.rb:19:in `call'
# /Users/tom/.rvm/gems/ruby-1.9.3-p429/gems/rack-1.4.5/lib/rack/handler/webrick.rb:59:in `service'
# /Users/tom/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
# /Users/tom/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
# /Users/tom/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
On a side note, adding config.action_dispatch.show_exceptions = true to config/environments/test.rb allows the test to pass, it does not explain why it is happening, it merely suppresses the warning

Rails isn't loading my JS properly - ERROR bad Request-Line `'

I have a Rails 3.2.3 app isn't consistently loading JS files. I just started working on the JS, so I'm not sure if this just started, or if it's been this way since I started it a few days ago.
The two other guys working on the project are not having any problems at all. But sometimes it loads all of my files, sometimes it skips some, there doesn't seem to be any pattern.
Sometimes it loads app.js, sometimes it doesn't. Same thing with the other js files.
I'm seeing the following show up multiple times in my rails log:
ERROR bad Request-Line `'.
I'm at a loss here...
application.js:
//= require jquery
//= require jquery_ujs
//= require util
//= require app
//= require_tree .
Here is what the log file is showing:
Started GET "/assets/user_manager.js?body=1" for 127.0.0.1 at 2012-11-07 18:02:13 -0500
Served asset /user_manager.js - 200 OK (0ms)
Started GET "/assets/util.js?body=1" for 127.0.0.1 at 2012-11-07 18:02:13 -0500
Served asset /util.js - 200 OK (0ms)
[2012-11-07 18:02:13] ERROR bad Request-Line `'.
[2012-11-07 18:02:13] ERROR bad Request-Line `'.
[2012-11-07 18:02:13] ERROR bad Request-Line `'.
Started GET "/assets/header/topnav/separator.png" for 127.0.0.1 at 2012-11-07 18:02:13 -0500
Served asset /header/topnav/separator.png - 200 OK (0ms)
Started GET "/assets/header/pagetitle-bg.png" for 127.0.0.1 at 2012-11-07 18:02:13 -0500
Served asset /header/pagetitle-bg.png - 200 OK (0ms)
[2012-11-07 18:02:13] ERROR bad Request-Line `'.
Started GET "/assets/header_bg.png" for 127.0.0.1 at 2012-11-07 18:02:13 -0500
Served asset /header_bg.png - 404 Not Found (3ms)
ActionController::RoutingError (No route matches [GET] "/assets/header_bg.png"):
actionpack (3.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.3) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.3) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.3) 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.3) 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.3) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.3) lib/rails/engine.rb:479:in `call'
railties (3.2.3) lib/rails/application.rb:220:in `call'
rack (1.4.1) lib/rack/c[2012-11-07 18:02:13] ERROR bad Request-Line `'.
ontent_length.rb:14:in `call'
railties (3.2.3) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/Users/rob/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/rob/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/rob/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
Rendered /Users/rob/.rvm/gems/ruby-1.9.3-p125#admin/gems/actionpack-3.2. 3/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.1ms)
Started GET "/assets/background/header_blueprint.png" for 127.0.0.1 at 2012-11-07 18:02:13 -0500
Served asset /background/header_blueprint.png - 200 OK (0ms)
Started GET "/assets/images/ui-icons_454545_256x240.png" for 127.0.0.1 at 2012-11-07 18:02:13 -0500
Served asset /images/ui-icons_454545_256x240.png - 404 Not Found (3ms)
ActionController::RoutingError (No route matches [GET] "/assets/images/ui-icons_454545_256x240.png"):
actionpack (3.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.3) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.3) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.3) 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.3) 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.3) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.3) lib/rails/engine.rb:479:in `call'
railties (3.2.3) lib/rails/application.rb:220:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.3) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/Users/rob/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/rob/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/rob/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
Rendered /Users/rob/.rvm/gems/ruby-1.9.3-p125#admin/gems/actionpack-3.2. 3/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.8ms)
[2012-11-07 18:02:13] ERROR bad Request-Line `'.
[2012-11-07 18:02:13] ERROR bad Request-Line `'.
[2012-11-07 18:02:13] ERROR bad Request-Line `'.
I had the same problem with JS and CSS files randomly failing to load in Google Chrome, this error showing in the logs:
ERROR bad Request-Line `'.
The problem must have been cookie related, though deleting the cookie did not work for me. I solved the problem by renaming they key in config/initializers/session_store.rb and then renaming it back once the problem was gone. Strange.

Mailgun HTTP POST to with Rails 3 - (undefined method `rewind' for #<String:0xb701ace0>)

Does anyone have any theories about this?
I have a feeling this is a Rails 3.x bug.
I'm using a service called mailgun that routes incoming e-mails to url's for further processing. Rails 3 chokes on these requests. Rails 2 does not.
I'm at a loss. I'm not sure exactly where the issue is.
Started POST "/posts/upload" for 174.37.214.195 at Fri Mar 11 20:22:41 -0500 2011
SQL (0.1ms) SET search_path TO public
SQL (0.2ms) SHOW client_min_messages
SQL (0.1ms) SET client_min_messages TO 'panic'
SQL (0.1ms) SET standard_conforming_strings = on
SQL (0.1ms) SET client_min_messages TO 'notice'
SQL (0.4ms) SET time zone 'UTC'
SQL (0.1ms) SHOW TIME ZONE
NoMethodError (undefined method `rewind' for #<String:0xb6d1c624>):
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.4/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (1.0ms)
Error during failsafe response: ActionView::Template::Error
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.4/lib/active_support/whiny_nil.rb:48:in `method_missing'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.4/lib/action_dispatch/http/parameters.rb:10:in `parameters'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.4/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb:3:in `__usr_lib_ruby_gems_____gems_actionpack_______lib_action_dispatch_middleware_templates_rescues_diagnostics_erb___359554262__609638518_0'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.4/lib/action_view/template.rb:135:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.4/lib/action_view/template.rb:135:in `render'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.4/lib/active_support/notifications.rb:54:in `instrument'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.4/lib/action_view/template.rb:127:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.4/lib/action_view/render/rendering.rb:59:in `_render_template'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.4/lib/active_support/notifications.rb:52:in `instrument'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.4/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.4/lib/active_support/notifications.rb:52:in `instrument'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.4/lib/action_view/render/rendering.rb:56:in `_render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.4/lib/action_view/render/rendering.rb:26:in `render_without_haml'
/usr/lib/ruby/gems/1.8/gems/haml-3.0.25/lib/haml/helpers/action_view_mods.rb:13:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.4/lib/action_dispatch/middleware/show_exceptions.rb:88:in `rescue_action_locally'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.4/lib/action_dispatch/middleware/show_exceptions.rb:68:in `render_exception'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.4/lib/action_dispatch/middleware/show_exceptions.rb:59:in `call'
/usr/lib/ruby/gems/1.8/gems/railties-3.0.4/lib/rails/rack/logger.rb:13:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/runtime.rb:17:in `call'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.4/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/lock.rb:11:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/lock.rb:11:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/lock.rb:11:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.4/lib/action_dispatch/middleware/static.rb:30:in `call'
/usr/lib/ruby/gems/1.8/gems/railties-3.0.4/lib/rails/application.rb:168:in `call'
/usr/lib/ruby/gems/1.8/gems/railties-3.0.4/lib/rails/application.rb:77:in `send'
/usr/lib/ruby/gems/1.8/gems/railties-3.0.4/lib/rails/application.rb:77:in `method_missing'
/usr/lib/ruby/gems/1.8/gems/railties-3.0.4/lib/rails/rack/log_tailer.rb:14:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/content_length.rb:13:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/handler/webrick.rb:52:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/handler/webrick.rb:13:in `run'
/usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/server.rb:213:in `start'
/usr/lib/ruby/gems/1.8/gems/railties-3.0.4/lib/rails/commands/server.rb:65:in `start'
/usr/lib/ruby/gems/1.8/gems/railties-3.0.4/lib/rails/commands.rb:30
/usr/lib/ruby/gems/1.8/gems/railties-3.0.4/lib/rails/commands.rb:27:in `tap'
/usr/lib/ruby/gems/1.8/gems/railties-3.0.4/lib/rails/commands.rb:27
script/rails:6:in `require'
script/rails:6
Started POST "/posts" for 174.37.214.196 at Fri Mar 11 20:24:24 -0500 2011
NoMethodError (undefined method `rewind' for #<String:0xb701ace0>):
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.4/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (1.1ms)
Two ideas: either your routing is configured differently, or there's "forgery protection" going on. Not exactly a rails expert here... :)