Twilio Ruby SMS: undefined method `empty?' - ruby-on-rails-4

I am trying to use twilio in a rails application. As part of the development I set up a simple controller using some hard-coded values (the input from the form that submits the POST request is, essentially, ignored). Here is the code of the controller:
class SmsController < ApplicationController
def send (dummy)
twilio_sid = "removed-for-privacy-reasons"
twilio_token = "removed-for-privacy-reasons"
twilio_phone_number = "removed-for-privacy-reasons"
number_to_send_to = "removed-for-privacy-reasons"
#twilio_client = Twilio::REST::Client.new twilio_sid, twilio_token
#twilio_client.account.sms.messages.create(
:from => twilio_phone_number,
:to => number_to_send_to,
:body => "This is a test of SendTextController"
)
end
end
The controller works fine - I am getting the hard-coded SMS at my mobile. However, I am getting the following exception at the web form:
undefined method `empty?' for Twilio::REST::SMS::Message:0x007f8df0e743b8
The full stack trace is here:
Application Trace | Framework Trace | Full Trace
twilio-ruby (3.12.2) lib/twilio-ruby/rest/instance_resource.rb:68:in `method_missing'
activesupport (4.1.5) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.1.5) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.5) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.5) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.5) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.5) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.5) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.5) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.5) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.5) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.5) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.5) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.5) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.1.5) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.5) lib/action_controller/metal.rb:232:in `block in action'
actionpack (4.1.5) lib/action_dispatch/routing/route_set.rb:82:in `call'
actionpack (4.1.5) lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
actionpack (4.1.5) lib/action_dispatch/routing/route_set.rb:50:in `call'
actionpack (4.1.5) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.5) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.1.5) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.5) lib/action_dispatch/routing/route_set.rb:678:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:35:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.1.5) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.5) lib/action_dispatch/middleware/flash.rb:254:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.1.5) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.1.5) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.1.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
activerecord (4.1.5) lib/active_record/migration.rb:380:in `call'
actionpack (4.1.5) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.5) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.5) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.5) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.5) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.5) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.5) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.5) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.5) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.5) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.5) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.5) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.5) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.5) 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.5) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.5) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.5) lib/rails/engine.rb:514:in `call'
railties (4.1.5) lib/rails/application.rb:144: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'
/Users/nnikolo/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
/Users/nnikolo/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
/Users/nnikolo/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
There is another SO thread reporting a similar problem but none of the solutions offered there worked for me. Can you help?

Twilio Evangelist here.
This is really interesting.
First a quick side note: you are using the SMS resource, which is deprecated in favour of Messages. You should use the following:
#twilio_client = Twilio::REST::Client.new twilio_sid, twilio_token
#twilio_client.account.messages.create(
:from => twilio_phone_number,
:to => number_to_send_to,
:body => "This is a test of SendTextController"
)
Notice I removed the .SMS part of that.
Secondly, and I'll admit I can't fully explain the details, I strongly suspect using send as your action name is calling all kinds of chaos. #send comes form Object and here you're overriding it, but Rails uses it for various different callbacks on the controller. I notice you've added (dummy) to your signature, but Ruby doesn't support method overloading.
I don't know why, but it seems that may be the problem. I created a simple Rails 4.0.4 with exactly your controller, and I had a similar problem:
undefined method `compile' for #<Twilio::REST::SMS::Message:0x007fea132761e0>
Rails.root: ~/so26076867
Application Trace | Framework Trace | Full Trace
twilio-ruby (3.12.2) lib/twilio-ruby/rest/instance_resource.rb:68:in `method_missing'
activesupport (4.0.4) lib/active_support/callbacks.rb:369:in `__define_callbacks'
activesupport (4.0.4) lib/active_support/callbacks.rb:79:in `run_callbacks'
actionpack (4.0.4) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (4.0.4) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.0.4) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.0.4) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.4) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.4) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.4) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.0.4) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
My rails app doesn't have ActiveRecord, so that may explain the some of difference. But noticed that the top of our stack traces are both coming from the callbacks code in Rails. When I renamed the action to test_sms it worked:
def test_sms
twilio_sid = "xxxx"
twilio_token = "yyyy"
twilio_phone_number = "zzzz"
number_to_send_to = "...."
#twilio_client = Twilio::REST::Client.new twilio_sid, twilio_token
#twilio_client.account.sms.messages.create(
:from => twilio_phone_number,
:to => number_to_send_to,
:body => "This is a test of SendTextController"
)
end
I'd be interested to hear if this works for you. I've seen weird behaviour in Ruby and in Rails when accidentally naming a method send, it always seems to cause chaos. Exactly why you get this error, I'm not sure. This is probably breaking something in Rails. I'm going to look into this week and see if I can figure it out.
Let me know if this works, else I'll have another crack at it.

xmjw's answer nails it. I got the same advice from Alex Chan from Twilio's support. Xmjw's answer is, however, more comprehensive as it mentions the deprecated API version.
I need to mention that I copied the code of the controller from Twilio's own blog but I renamed for no particular reason the controller method to "send". The code produced "wrong number of arguments (1 for 0)" so I added a dummy parameter to the "send" method.
I followed the advice of Xmjw and Alex Chan and re-named the controller method. I used the name "send-text_message" which was used in the code snippet on Twilio's blog. I started getting "missing template" but this is not related to twilio. Putting
head :ok
at the end of the send_text_message method removed that error message. I got that from one of the replies at Template is missing.
In short - the code snippet on Twilio's blog is somewhat outdated but the replies of Xmjw and of twilio's Alex Chan sorted it out. It is really encouraging to see such good support for Twilio's API. I am really excited to work with it - thank you, guys!

Related

ActionController::RoutingError (No route matches [GET] "/images/picture.jpg"):

I seem to have broken something in my rails 4.2 development environment. I went to change an image on one of my apps pages with another image I placed in the same location as the original, app/assets/images/picture.jpg but the new image won't render, and I can see in the source that unlike other images it's not being fingerprinted and still shows as picture.jpg in the source.
I'm not sure how to debug this and I haven't been able to find a working solution online. This is what prints in my rails server log:
Started GET "/images/picture.jpg" for ::1 at 2015-06-15 10:56:28 +0800
ActionController::RoutingError (No route matches [GET] "/images/picture.jpg"):
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.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.1) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.1) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.1) lib/rack/lock.rb:17:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.1) lib/rack/sendfile.rb:113:in `call'
railties (4.2.0) lib/rails/engine.rb:518:in `call'
railties (4.2.0) lib/rails/application.rb:164:in `call'
rack (1.6.1) lib/rack/lock.rb:17:in `call'
rack (1.6.1) lib/rack/content_length.rb:15:in `call'
rack (1.6.1) lib/rack/handler/webrick.rb:89:in `service'
/home/me/.rbenv/versions/2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
/home/me/.rbenv/versions/2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
/home/me/.rbenv/versions/2.2.1/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
Rendered /home/me/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/web-console-2.0.0.beta3/lib/action_dispatch/templates/rescues/_trace.html.erb (1.0ms)
Rendered /home/me/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/web-console-2.0.0.beta3/lib/action_dispatch/templates/rescues/routing_error.html.erb within rescues/layout (19.6ms)
Thanks for any help!
Alxs

Rails 4 upgrade JSON::ParseError for old sessions

After upgrading to Rails 4.1.4 from Rails 3.2, accessing the application with an existing session (from the older Rails 3.2 version) causes an internal server error. backtrace:
JSON::ParserError - 795: unexpected token at {
I"session_id:ETI"%fa78a4ee07ac952c9b034ebc6199f30b;':
/Users/.../.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/json/common.rb:155:in `parse'
actionpack (4.1.4) lib/action_dispatch/middleware/cookies.rb:388:in `load'
actionpack (4.1.4) lib/action_dispatch/middleware/cookies.rb:428:in `deserialize'
actionpack (4.1.4) lib/action_dispatch/middleware/cookies.rb:183:in `verify_and_upgrade_legacy_signed_message'
actionpack (4.1.4) lib/action_dispatch/middleware/cookies.rb:550:in `[]'
actionpack (4.1.4) lib/action_dispatch/middleware/session/cookie_store.rb:114:in `get_cookie'
actionpack (4.1.4) lib/action_dispatch/middleware/session/cookie_store.rb:90:in `block in unpacked_cookie_data'
actionpack (4.1.4) lib/action_dispatch/middleware/session/abstract_store.rb:51:in `stale_session_check!'
actionpack (4.1.4) lib/action_dispatch/middleware/session/cookie_store.rb:89:in `unpacked_cookie_data'
actionpack (4.1.4) lib/action_dispatch/middleware/session/cookie_store.rb:83:in `block in extract_session_id'
actionpack (4.1.4) lib/action_dispatch/middleware/session/abstract_store.rb:51:in `stale_session_check!'
actionpack (4.1.4) lib/action_dispatch/middleware/session/cookie_store.rb:82:in `extract_session_id'
actionpack (4.1.4) lib/action_dispatch/request/session.rb:49:in `block in []'
actionpack (4.1.4) lib/action_dispatch/request/session.rb:48:in `[]'
actionpack (4.1.4) lib/action_dispatch/request/session.rb:70:in `id'
rack (1.5.2) lib/rack/session/abstract/id.rb:282:in `current_session_id'
rack (1.5.2) lib/rack/session/abstract/id.rb:288:in `session_exists?'
actionpack (4.1.4) lib/action_dispatch/request/session.rb:152:in `exists?'
actionpack (4.1.4) lib/action_dispatch/request/session.rb:172:in `load_for_read!'
actionpack (4.1.4) lib/action_dispatch/request/session.rb:89:in `[]'
warden (1.2.3) lib/warden/session_serializer.rb:30:in `fetch'
warden (1.2.3) lib/warden/proxy.rb:212:in `user'
warden (1.2.3) lib/warden/proxy.rb:318:in `_perform_authentication'
warden (1.2.3) lib/warden/proxy.rb:104:in `authenticate'
warden (1.2.3) lib/warden/proxy.rb:114:in `authenticate?'
devise (3.2.4) lib/devise/rails/routes.rb:460:in `block in constraints_for'
actionpack (4.1.4) lib/action_dispatch/routing/mapper.rb:38:in `block in matches?'
actionpack (4.1.4) lib/action_dispatch/routing/mapper.rb:36:in `matches?'
actionpack (4.1.4) lib/action_dispatch/routing/mapper.rb:45:in `call'
actionpack (4.1.4) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.4) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.4) lib/action_dispatch/routing/route_set.rb:678:in `call'
...
I tried to change the session cookie key name, but it seems to be stuck on session_id.
# initializers/session_store.rb
MyApp::Application.config.session_store :cookie_store, key: 'myapp_session'
Please help! A great solution would also be to delete all session cookies before they hit the rails middleware, but i have no idea how to do that..
Found the answer here: https://github.com/rails/rails/issues/15111
My settings had
# initializers/cookie_serializer.rb
Rails.application.config.action_dispatch.cookies_serializer = :json
I changed it to
Rails.application.config.action_dispatch.cookies_serializer = :hybrid
And that did the trick
If you're comfortable with changing your secret key, then it will solve the problem, and I can confirm that people with old cookies will not encounter a 500 error.
Run rake secret to generate a new secret.
If you've implemented config/secrets.yml, put the new secret in there. Otherwise, if you still have your secret in config/initializers/secret_token.rb, put it in there.
Leave your config/initializers/session_store.rb file alone -- you don't need to change it.
In config/initializers/cookie_store.rb, change it to :json:
# Be sure to restart your server when you modify this file.
Rails.application.config.action_dispatch.cookies_serializer = :json
I can confirm that this works, even when your browser is storing an old session cookie. By changing the secret, when someone with an old session cookie visits your site, the server simply ignores the old session state and creates a new session. No 500 error.
I just had the same problem and used the answer here and all was fixed.
After reading the comments though I found that just changing the secret also fixed the problem, as it should I suppose.
I think changing the secret is a better solution to the problem than switching to :hybrid like #Thibaut Barrère stated in the comments

Ruby on Rails Routing error while accessing form my local browser

I have the following error while I am viewing my webpages in browser.
book is my directory in that edit.erb is my view page
route.rb
LibrarySystem::Application.routes.draw do
get 'book#edit'
end
while I am accessing :3000/book/edit" it showing the following error
ActionController::RoutingError (No route matches [GET] "/book/edit"):
actionpack (4.0.3) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (4.0.3) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.3) lib/rails/rack/logger.rb`enter code here`:38:in `call_app'
railties (4.0.3) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.0.3) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.3) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.3) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.3) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.0.3) 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.3) 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.3) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.0.3) lib/rails/engine.rb:511:in `call'
railties (4.0.3) 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:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
Rendered c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-4.0.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.0ms)
Rendered c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-4.0.3/lib/action_dispatch/middleware/templates/routes/_table.html.erb (15.6ms)
Rendered c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-4.0.3/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (62.5ms)
Your route is not defined correctly, I would recommend you to read through the commented out part of your routes.rb file for examples.
Oh well, I'll expand my answer. In your comment I can see you have some basic CRUD routes. The easiest way to define these routes is the following:
resources :books
Now check rake routes to see what routes are generated. You might not need them all, but you can set limitations through only or except. Example:
resources :books, except: [:show]
Now if you want a custom route for an individual book, you can add a member to your resources, like:
resources :books do
member do
post 'upvote'
end
end
Be aware though, if you want custom routes you should have an action with the same name, in this case upvote, defined in you controller.
If you want to set a route for a collection of books you can use collection instead of member. It is important to think about how your URLs should look like and if you want the route for either an individual book or a collection of books.
Calling routes for an individual book passes along the id of that book. Basic URL: ../book/1/edit. This is necessary for the controller, because you need the id params to work with. You can also make the URL more pretty by naming your route. Example:
get 'summary', to: 'books#show, as: :summary
Right, I can go on all day like this, but you should probably check the railsguides on this subject first.
Replace
LibrarySystem::Application.routes.draw do
get 'book#edit'
end
WITH
LibrarySystem::Application.routes.draw do
get 'book/edit'
end
You can define a shortcut route as get 'book/edit' which Rails can interpret correctly and map to book#edit plus create a named route as book_edit_path as mentioned below:
book_edit GET /book/edit(.:format) book#edit
Writing the route as get 'book#edit' would probably give you an error right at time you try to start the server or try to access a page(if it was already started):
ArgumentError (missing :controller):
That makes me believe that the scenario you shared is incorrect as defining your route as
get 'book#edit'
would not result in
ActionController::RoutingError (No route matches [GET] "/book/edit").

Rails ActionView::MissingTemplate error?

I've been at this for the better part of a day, was hoping someone more knowledgable than me could fix in two seconds.
I have a spree / rails app that is working fine on my local development box but on the server it keeps crashing with this error when I try to post to "/orders/populate".
It says MissingTemplate, can't tell if that's a warning or if that was in fact the fatal error. Anyway if I go to site.com/404 The page is working fine, I have this route get "404" => "pages#error404" that sends it to a working page.
I, [2014-02-25T06:33:01.693899 #18826] INFO -- : Started POST "/orders/populate" for 65.53.4.81 at 2014-02-25 06:33:01 +0100
I, [2014-02-25T06:33:02.142190 #18826] INFO -- : Processing by Spree::OrdersController#populate as HTML
I, [2014-02-25T06:33:02.147701 #18826] INFO -- : Parameters: {"utf8"=>"✓", "authenticity_token"=>"ChLxG3GWeEK8S31WdDdOZvVG9/9nsVVsQYzHuog6iZM=", "variants"=>{"6340"=>"1"}}
D, [2014-02-25T06:33:02.212119 #18826] DEBUG -- : Spree::User Load (5.1ms) SELECT "spree_users".* FROM "spree_users" WHERE "spree_users"."id" = 4 ORDER BY "spree_users"."id" ASC LIMIT 1
D, [2014-02-25T06:33:02.543884 #18826] DEBUG -- : Spree::Preference Load (1.9ms) SELECT "spree_preferences".* FROM "spree_preferences" WHERE "spree_preferences"."key" = 'spree/frontend_configuration/locale' LIMIT 1
D, [2014-02-25T06:33:02.580552 #18826] DEBUG -- : Spree::Order Load (7.0ms) SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."user_id" = $1 AND "spree_orders"."completed_at" IS NULL AND "spree_orders"."created_by_id" = 4 ORDER BY created_at DESC LIMIT 1 [["user_id", 4]]
D, [2014-02-25T06:33:02.709049 #18826] DEBUG -- : Spree::Order Load (1.1ms) SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."id" = 14 AND "spree_orders"."currency" = 'USD' LIMIT 1
D, [2014-02-25T06:33:02.780039 #18826] DEBUG -- : Spree::Adjustment Load (6.9ms) SELECT "spree_adjustments".* FROM "spree_adjustments" WHERE "spree_adjustments"."adjustable_type" = 'Spree::Order' AND "spree_adjustments"."adjustable_id" IN (14) ORDER BY spree_adjustments.created_at ASC
D, [2014-02-25T06:33:02.785602 #18826] DEBUG -- : Spree::Order Load (1.2ms) SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."number" IS NULL LIMIT 1
D, [2014-02-25T06:33:02.810045 #18826] DEBUG -- : (4.3ms) SELECT COUNT(*) FROM "spree_roles" INNER JOIN "spree_roles_users" ON "spree_roles"."id" = "spree_roles_users"."role_id" WHERE "spree_roles_users"."user_id" = $1 AND "spree_roles"."name" = 'admin' [["user_id", 4]]
D, [2014-02-25T06:33:02.825458 #18826] DEBUG -- : Spree::Variant Load (4.6ms) SELECT "spree_variants".* FROM "spree_variants" WHERE "spree_variants"."id" = $1 AND ("spree_variants".deleted_at IS NULL) LIMIT 1 [["id", "6340"]]
D, [2014-02-25T06:33:02.909932 #18826] DEBUG -- : Spree::LineItem Load (3.4ms) SELECT "spree_line_items".* FROM "spree_line_items" WHERE "spree_line_items"."order_id" = $1 ORDER BY created_at ASC [["order_id", 14]]
D, [2014-02-25T06:33:02.971996 #18826] DEBUG -- : (0.7ms) BEGIN
D, [2014-02-25T06:33:03.145149 #18826] DEBUG -- : Spree::Variant Load (1.7ms) SELECT "spree_variants".* FROM "spree_variants" WHERE "spree_variants"."id" = $1 ORDER BY "spree_variants"."id" ASC LIMIT 1 [["id", 6340]]
D, [2014-02-25T06:33:03.164429 #18826] DEBUG -- : Spree::Product Load (4.8ms) SELECT "spree_products".* FROM "spree_products" WHERE "spree_products"."id" = $1 ORDER BY "spree_products"."id" ASC LIMIT 1 [["id", 6334]]
D, [2014-02-25T06:33:03.236665 #18826] DEBUG -- : Spree::TaxCategory Load (2.3ms) SELECT "spree_tax_categories".* FROM "spree_tax_categories" WHERE "spree_tax_categories"."id" = $1 AND ("spree_tax_categories".deleted_at IS NULL) LIMIT 1 [["id", 1]]
D, [2014-02-25T06:33:03.238493 #18826] DEBUG -- : (0.7ms) ROLLBACK
I, [2014-02-25T06:33:03.252370 #18826] INFO -- : Completed 500 Internal Server Error in 1104ms
F, [2014-02-25T06:33:03.256794 #18826] FATAL -- :
ActionView::MissingTemplate (Missing template home/toner/public/404 with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee, :haml, :rabl], :versions=>[:v1]}. Searched in:
* "/home/toner/app/views"
* "/usr/local/rvm/gems/ruby-2.0.0-p247/bundler/gems/spree_gateway-ab4dcb885418/app/views"
* "/usr/local/rvm/gems/ruby-2.0.0-p247/bundler/gems/spree_auth_devise-c27fac85b082/app/views"
* "/usr/local/rvm/gems/ruby-2.0.0-p247/gems/devise-3.0.3/app/views"
* "/usr/local/rvm/gems/ruby-2.0.0-p247/gems/spree_frontend-2.1.2/app/views"
* "/usr/local/rvm/gems/ruby-2.0.0-p247/gems/spree_backend-2.1.2/app/views"
* "/usr/local/rvm/gems/ruby-2.0.0-p247/gems/spree_api-2.1.2/app/views"
* "/usr/local/rvm/gems/ruby-2.0.0-p247/gems/spree_core-2.1.2/app/views"
* "/usr/local/rvm/gems/ruby-2.0.0-p247/gems/kaminari-0.14.1/app/views"
* "/home/toner"
* "/"
):
actionpack (4.0.0) lib/action_view/path_set.rb:46:in `find'
actionpack (4.0.0) lib/action_view/lookup_context.rb:115:in `find'
actionpack (4.0.0) lib/action_view/renderer/abstract_renderer.rb:18:in `find_template'
actionpack (4.0.0) lib/action_view/renderer/template_renderer.rb:27:in `block in determine_template'
actionpack (4.0.0) lib/action_view/lookup_context.rb:136:in `with_fallbacks'
actionpack (4.0.0) lib/action_view/renderer/abstract_renderer.rb:18:in `with_fallbacks'
actionpack (4.0.0) lib/action_view/renderer/template_renderer.rb:27:in `determine_template'
actionpack (4.0.0) lib/action_view/renderer/template_renderer.rb:8:in `render'
actionpack (4.0.0) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionpack (4.0.0) lib/action_view/renderer/renderer.rb:23:in `render'
actionpack (4.0.0) lib/abstract_controller/rendering.rb:127:in `_render_template'
actionpack (4.0.0) lib/action_controller/metal/streaming.rb:219:in `_render_template'
actionpack (4.0.0) lib/abstract_controller/rendering.rb:120:in `render_to_body'
actionpack (4.0.0) lib/action_controller/metal/rendering.rb:33:in `render_to_body'
actionpack (4.0.0) lib/action_controller/metal/renderers.rb:26:in `render_to_body'
actionpack (4.0.0) lib/abstract_controller/rendering.rb:97:in `render'
actionpack (4.0.0) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
activesupport (4.0.0) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
activesupport (4.0.0) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (4.0.0) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:40:in `render'
spree_core (2.1.2) lib/spree/core/controller_helpers/common.rb:57:in `block (2 levels) in render_404'
actionpack (4.0.0) lib/action_controller/metal/mime_responds.rb:191:in `call'
actionpack (4.0.0) lib/action_controller/metal/mime_responds.rb:191:in `respond_to'
spree_core (2.1.2) lib/spree/core/controller_helpers/common.rb:56:in `render_404'
activesupport (4.0.0) lib/active_support/rescuable.rb:81:in `call'
activesupport (4.0.0) lib/active_support/rescuable.rb:81:in `rescue_with_handler'
actionpack (4.0.0) lib/action_controller/metal/rescue.rb:15:in `rescue_with_handler'
actionpack (4.0.0) lib/action_controller/metal/rescue.rb:32:in `rescue in process_action'
actionpack (4.0.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.0.0) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.0) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.0.0) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (4.0.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.0.0) lib/abstract_controller/base.rb:136:in `process'
actionpack (4.0.0) lib/abstract_controller/rendering.rb:44:in `process'
actionpack (4.0.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.0.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.0.0) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:in `call'
railties (4.0.0) lib/rails/engine.rb:511:in `call'
railties (4.0.0) lib/rails/railtie/configurable.rb:30:in `method_missing'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:35:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/flash.rb:241:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/cookies.rb:486:in `call'
activerecord (4.0.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.0) lib/active_support/callbacks.rb:373:in `_run__891893256__call__callbacks'
activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:17: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'
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-2.0.0-p247/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
/usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
/usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
It is looking for the 404.html in the public/ directory, make sure the file is there.

Thin Server Permission and Daemonizing Problems

I'm trying to deploy Redmine 2.x via Thin and have run into a couple of different problems. The first is, when testing via webrick I can successfully navigate Redmine anonymously. I can even login, however after submitting the form I receive an application error. Here is the production.log relevant parts:
Successful authentication for 'admin' from 97.79.126.223 at Fri Feb 01 00:14:04 UTC 2013
Redirected to http://54.235.144.11:3000/
Completed 302 Found in 67ms (ActiveRecord: 37.3ms)
NoMethodError (undefined method `options' for {:ctime=>1359677644, :user_id=>1, :atime=>1359677644}:Hash):
rack (1.5.1) lib/rack/session/abstract/id.rb:321:in `commit_session'
rack (1.5.1) lib/rack/session/abstract/id.rb:218:in `context'
rack (1.5.1) lib/rack/session/abstract/id.rb:212:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.11) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
activesupport (3.2.11) lib/active_support/callbacks.rb:405:in `_run__750860825__call__4__callbacks'
activesupport (3.2.11) lib/active_support/callbacks.rb:405:in `send'
activesupport (3.2.11) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.11) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.11) lib/active_support/callbacks.rb:81:in `send'
activesupport (3.2.11) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.11) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.11) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.11) lib/rails/rack/logger.rb:16:in `call'
activesupport (3.2.11) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.11) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.5.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.11) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.5.1) lib/rack/lock.rb:17:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/static.rb:62:in `call'
rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
rack-cache (1.2) lib/rack/cache/context.rb:143:in `pass'
rack-cache (1.2) lib/rack/cache/context.rb:155:in `invalidate'
rack-cache (1.2) lib/rack/cache/context.rb:71:in `call!'
rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
railties (3.2.11) lib/rails/engine.rb:479:in `call'
railties (3.2.11) lib/rails/application.rb:223:in `call'
rack (1.5.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.11) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.5.1) lib/rack/handler/webrick.rb:60: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'
rack (1.5.1) lib/rack/handler/webrick.rb:14:in `run'
rack (1.5.1) lib/rack/server.rb:264:in `start'
railties (3.2.11) lib/rails/commands/server.rb:70:in `start'
railties (3.2.11) lib/rails/commands.rb:55
railties (3.2.11) lib/rails/commands.rb:50:in `tap'
railties (3.2.11) lib/rails/commands.rb:50
script/rails:6:in `require'
script/rails:6
I've received this error both deploying with Thin and Webrick. I've never encountered this error with redmine before, regardless of how it is deployed.
The other problem I'm facing is how to start the thin servers. When I'm in the Rails directory and supply sudo thin start Thin successfully starts, however, if I try to start thin via sudo /etc/init.d/thin start I get this lovely error
>> Exiting!
/usr/lib64/ruby/gems/1.8/gems/eventmachine-1.0.0/lib/eventmachine.rb:528:in `start_unix_server': no unix-domain acceptor (RuntimeError)
from /usr/lib64/ruby/gems/1.8/gems/eventmachine-1.0.0/lib/eventmachine.rb:528:in `start_server'
from /usr/lib64/ruby/gems/1.8/gems/eventmachine-1.0.0/lib/eventmachine.rb:548:in `start_unix_domain_server'
from /usr/lib64/ruby/gems/1.8/gems/thin-1.5.0/lib/thin/backends/unix_server.rb:19:in `connect'
from /usr/lib64/ruby/gems/1.8/gems/thin-1.5.0/lib/thin/backends/base.rb:55:in `start'
from /usr/lib64/ruby/gems/1.8/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `call'
from /usr/lib64/ruby/gems/1.8/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run_machine'
from /usr/lib64/ruby/gems/1.8/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run'
from /usr/lib64/ruby/gems/1.8/gems/thin-1.5.0/lib/thin/backends/base.rb:63:in `start'
from /usr/lib64/ruby/gems/1.8/gems/thin-1.5.0/lib/thin/server.rb:159:in `start'
from /usr/lib64/ruby/gems/1.8/gems/thin-1.5.0/lib/thin/controllers/controller.rb:86:in `start'
from /usr/lib64/ruby/gems/1.8/gems/thin-1.5.0/lib/thin/runner.rb:187:in `send'
from /usr/lib64/ruby/gems/1.8/gems/thin-1.5.0/lib/thin/runner.rb:187:in `run_command'
from /usr/lib64/ruby/gems/1.8/gems/thin-1.5.0/lib/thin/runner.rb:152:in `run!'
from /usr/lib64/ruby/gems/1.8/gems/thin-1.5.0/bin/thin:6
from /usr/bin/thin:19:in `load'
from /usr/bin/thin:19
Here is my redmine.yml thin config file
servers: 3
chdir: /www/redmine.guidelinecentral.com
user: apache
log: /var/log/thin/redmine.log
daemonize: true
pid: /var/run/thin/redmine.pid
group: apahce
require: []
timeout: 30
wait: 30
max_persistent_conns: 100
socket: /var/run/redmine/sockets/thin.sock
max_conns: 1024
environment: production
I was not able to solve this issue and ended up doing a reinstall of both Thin and Redmine. I think there was a bad gem somewhere.