MySQL server has gone away in Rails app hosted on Google Compute Engine connecting to Cloud SQL - ruby-on-rails-3

I occasionally get MySQL server has gone away on my Rails 3.2.13/Ruby 1.9.3 app, hosted on a Google Compute Engine instance, connecting to a Cloud SQL D1 (512 MB) instance. The traffic is very low. The problem goes away when the site is reloaded, but it's too late since an HTTP 500 is already produced.
Any suggestions on what to tune? Does the MySQL server disconnect due to low traffic?
ActiveRecord::StatementInvalid (Mysql2::Error: MySQL server has gone away: SHOW
FULL FIELDS FROM `users`):
activerecord (3.2.13) lib/active_record/connection_adapters/abstract_mysql_ada
pter.rb:245:in `query'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract_mysql_ada
pter.rb:245:in `block in execute'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract_adapter.r
b:280:in `block in log'
activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `execute'
activerecord (3.2.13) lib/active_record/connection_adapters/mysql2_adapter.rb:211:in `execute'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:259:in `execute_and_free'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:426:in `columns'
activerecord (3.2.13) lib/active_record/connection_adapters/schema_cache.rb:12:in `block in initialize'
activerecord (3.2.13) lib/active_record/model_schema.rb:228:in `yield'
activerecord (3.2.13) lib/active_record/model_schema.rb:228:in `default'
activerecord (3.2.13) lib/active_record/model_schema.rb:228:in `columns'
activerecord (3.2.13) lib/active_record/model_schema.rb:237:in `columns_hash'
activerecord (3.2.13) lib/active_record/locking/optimistic.rb:131:in `locking_enabled?'
activerecord (3.2.13) lib/active_record/relation.rb:170:in `exec_queries'
activerecord (3.2.13) lib/active_record/relation.rb:160:in `block in to_a'
activerecord (3.2.13) lib/active_record/explain.rb:41:in `logging_query_plan'
activerecord (3.2.13) lib/active_record/relation.rb:159:in `to_a'
activerecord (3.2.13) lib/active_record/relation/finder_methods.rb:380:in `find_first'
activerecord (3.2.13) lib/active_record/relation/finder_methods.rb:122:in `first'
orm_adapter (0.4.0) lib/orm_adapter/adapters/active_record.rb:17:in `get'
devise (2.2.4) lib/devise/models/authenticatable.rb:208:in `serialize_from_session'
devise (2.2.4) lib/devise.rb:437:in `block (2 levels) in configure_warden!'
warden (1.2.1) lib/warden/session_serializer.rb:35:in `fetch'
warden (1.2.1) lib/warden/proxy.rb:212:in `user'
warden (1.2.1) lib/warden/proxy.rb:318:in `_perform_authentication'
warden (1.2.1) lib/warden/proxy.rb:127:in `authenticate!'
devise (2.2.4) lib/devise/controllers/helpers.rb:48:in `authenticate_user!'
activesupport (3.2.13) lib/active_support/callbacks.rb:407:in `run1684931682470039459process_action2800431035017339248_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.13) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.13) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.13) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.13) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:in `call'
omniauth (1.1.4) lib/omniauth/strategy.rb:184:in `call!'
omniauth (1.1.4) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.1.4) lib/omniauth/strategy.rb:184:in `call!'
omniauth (1.1.4) lib/omniauth/strategy.rb:164:in `call'
warden (1.2.1) lib/warden/manager.rb:35:in `block in call'
warden (1.2.1) lib/warden/manager.rb:34:in `catch'
warden (1.2.1) lib/warden/manager.rb:34:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.5) lib/rack/etag.rb:23:in `call'
rack (1.4.5) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.13) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connectio
n_pool.rb:479:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:28:in `block i
n call'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `run_280652940
067824407_call1265643099882031984_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_call_callb
acks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `
call'
actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `c
all'
railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.13) 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.13) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
railties (3.2.13) lib/rails/engine.rb:479:in `call'
railties (3.2.13) lib/rails/application.rb:223:in `call'
railties (3.2.13) lib/rails/railtie/configurable.rb:30:in `method_missing'
unicorn (4.6.3) lib/unicorn/http_server.rb:552:in `process_client'
unicorn (4.6.3) lib/unicorn/http_server.rb:632:in `worker_loop'
unicorn (4.6.3) lib/unicorn/http_server.rb:500:in `spawn_missing_workers'
unicorn (4.6.3) lib/unicorn/http_server.rb:511:in `maintain_worker_count'
unicorn (4.6.3) lib/unicorn/http_server.rb:277:in `join'
unicorn (4.6.3) bin/unicorn:126:in `<top (required)>'
/home/mparaz/.rvm/gems/ruby-1.9.3-p545#moovd/bin/unicorn:23:in `load'
/home/mparaz/.rvm/gems/ruby-1.9.3-p545#moovd/bin/unicorn:23:in `<main>'
/home/mparaz/.rvm/gems/ruby-1.9.3-p545#moovd/bin/ruby_executable_hooks:15:in `eval'
/home/mparaz/.rvm/gems/ruby-1.9.3-p545#moovd/bin/ruby_executable_hooks:15:in `<main>'

The observed behavior, most likely, is a result of the billing plan configured for the instance. If 'per use' billing plan is used; the instance will spin up when accessed and will continue to be up 15 min after the last access.
For more details take a look at "Pricing and Billing" section here.

Another consideration is that Google Compute Engine kills times out idle connections. This issue and the workaround are described in the old Cloud SQL Google Group:
https://groups.google.com/forum/#!msg/google-cloud-sql-discuss/cLLxUxiS5ck/c5dsYCvZhDEJ
The relevant Google Compute Engine documentation:
https://developers.google.com/compute/docs/networking#overview

Related

How to Get Tags Linkable?

I was using this railscast episode: http://railscasts.com/episodes/382-tagging, which suggested this gem: https://github.com/mbleigh/acts-as-taggable-on,
and all was good to go until I clicked on a User created tag link, which is suppose to then list out every instance of the tag clicked, but instead I got this error message:
SQLite3::SQLException: near "values": syntax error: SELECT "values".* FROM "values" JOIN taggings values_taggings_5183317 ON values_taggings_5183317.taggable_id = values.id AND values_taggings_5183317.taggable_type = 'Value' AND values_taggings_5183317.tag_id = 2
Can you please help me?
# _form
<div class="form-group">
<%= f.text_field :tag_list, class: 'form-control', placeholder: 'Enter Tag(s)' %>
</div>
# Controller
def index
if params[:tag]
#values = Value.tagged_with(params[:tag])
else
#values = Value.order('RANDOM()')
end
end
def value_params
params.require(:value).permit(:name, :tag_list)
end
end
# index
<td class="category">
<b><%= raw value.tag_list.map { |t| link_to t, tag_path(t) }.join(', ') %> </b></td>
# routes
get 'tags/:tag', to: 'values#index', as: :tag
sqlite3 (1.3.10) lib/sqlite3/database.rb:91:in `initialize'
sqlite3 (1.3.10) lib/sqlite3/database.rb:91:in `new'
sqlite3 (1.3.10) lib/sqlite3/database.rb:91:in `prepare'
activerecord (4.2.0.rc3) lib/active_record/connection_adapters/sqlite3_adapter.rb:300:in `block in exec_query'
activerecord (4.2.0.rc3) lib/active_record/connection_adapters/abstract_adapter.rb:466:in `block in log'
activesupport (4.2.0.rc3) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activerecord (4.2.0.rc3) lib/active_record/connection_adapters/abstract_adapter.rb:460:in `log'
activerecord (4.2.0.rc3) lib/active_record/connection_adapters/sqlite3_adapter.rb:297:in `exec_query'
activerecord (4.2.0.rc3) lib/active_record/connection_adapters/abstract/database_statements.rb:336:in `select'
activerecord (4.2.0.rc3) lib/active_record/connection_adapters/abstract/database_statements.rb:32:in `select_all'
activerecord (4.2.0.rc3) lib/active_record/connection_adapters/abstract/query_cache.rb:68:in `block in select_all'
activerecord (4.2.0.rc3) lib/active_record/connection_adapters/abstract/query_cache.rb:83:in `cache_sql'
activerecord (4.2.0.rc3) lib/active_record/connection_adapters/abstract/query_cache.rb:68:in `select_all'
activerecord (4.2.0.rc3) lib/active_record/querying.rb:39:in `find_by_sql'
activerecord (4.2.0.rc3) lib/active_record/relation.rb:638:in `exec_queries'
activerecord (4.2.0.rc3) lib/active_record/relation.rb:514:in `load'
activerecord (4.2.0.rc3) lib/active_record/relation.rb:243:in `to_a'
activerecord (4.2.0.rc3) lib/active_record/relation/delegation.rb:46:in `each'
app/views/values/index.html.erb:10:in `_app_views_values_index_html_erb__4435347718394186207_70115274036880'
actionview (4.2.0.rc3) lib/action_view/template.rb:145:in `block in render'
activesupport (4.2.0.rc3) lib/active_support/notifications.rb:166:in `instrument'
actionview (4.2.0.rc3) lib/action_view/template.rb:333:in `instrument'
actionview (4.2.0.rc3) lib/action_view/template.rb:143:in `render'
actionview (4.2.0.rc3) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
actionview (4.2.0.rc3) lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
activesupport (4.2.0.rc3) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.0.rc3) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.0.rc3) lib/active_support/notifications.rb:164:in `instrument'
actionview (4.2.0.rc3) lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
actionview (4.2.0.rc3) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
actionview (4.2.0.rc3) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
actionview (4.2.0.rc3) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (4.2.0.rc3) lib/action_view/renderer/template_renderer.rb:14:in `render'
actionview (4.2.0.rc3) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (4.2.0.rc3) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (4.2.0.rc3) lib/action_view/rendering.rb:100:in `_render_template'
actionpack (4.2.0.rc3) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (4.2.0.rc3) lib/action_view/rendering.rb:83:in `render_to_body'
actionpack (4.2.0.rc3) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
actionpack (4.2.0.rc3) lib/action_controller/metal/renderers.rb:37:in `render_to_body'
actionpack (4.2.0.rc3) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.2.0.rc3) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.2.0.rc3) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
activesupport (4.2.0.rc3) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/Users/galli01anthony/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
activesupport (4.2.0.rc3) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.2.0.rc3) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
actionpack (4.2.0.rc3) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (4.2.0.rc3) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.2.0.rc3) lib/action_controller/metal/instrumentation.rb:40:in `render'
actionpack (4.2.0.rc3) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.2.0.rc3) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (4.2.0.rc3) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.0.rc3) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.0.rc3) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:151:in `call'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:151:in `call'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:234:in `call'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:234:in `call'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:92:in `call'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:734:in `_run_process_action_callbacks'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0.rc3) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.0.rc3) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.0.rc3) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.2.0.rc3) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.0.rc3) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.0.rc3) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.0.rc3) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.0.rc3) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.0.rc3) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.0.rc3) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.0.rc3) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.0.rc3) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.2.0.rc3) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.0.rc3) lib/action_controller/metal.rb:236:in `block in action'
actionpack (4.2.0.rc3) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (4.2.0.rc3) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (4.2.0.rc3) lib/action_dispatch/routing/route_set.rb:42:in `serve'
actionpack (4.2.0.rc3) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.0.rc3) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.0.rc3) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.0.rc3) lib/action_dispatch/routing/route_set.rb:802: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.6.0) lib/rack/etag.rb:24:in `call'
rack (1.6.0) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.0) lib/rack/head.rb:13:in `call'
actionpack (4.2.0.rc3) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.0.rc3) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.0) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.0) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.0.rc3) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.0.rc3) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.0.rc3) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
activerecord (4.2.0.rc3) lib/active_record/migration.rb:378:in `call'
actionpack (4.2.0.rc3) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:88:in `call'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
activesupport (4.2.0.rc3) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0.rc3) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.0.rc3) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.0.rc3) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.0.rc3) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.2.0.rc3) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.0.rc3) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.0.rc3) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.0.rc3) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.0.rc3) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.0.rc3) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.0.rc3) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.0.rc3) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.0) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.0) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.0.rc3) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.0) lib/rack/lock.rb:17:in `call'
actionpack (4.2.0.rc3) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.0) lib/rack/sendfile.rb:113:in `call'
railties (4.2.0.rc3) lib/rails/engine.rb:518:in `call'
railties (4.2.0.rc3) lib/rails/application.rb:164:in `call'
rack (1.6.0) lib/rack/lock.rb:17:in `call'
rack (1.6.0) lib/rack/content_length.rb:15:in `call'
rack (1.6.0) lib/rack/handler/webrick.rb:89:in `service'
/Users/galli01anthony/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
/Users/galli01anthony/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
/Users/galli01anthony/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
Thanks in advance!!!
I think the problem is twofold.
The token "values" is a reserved word in standard SQL. As insert into table_name values (...);.
You use it without double quotes, which are required in standard SQL for reserved words used as identifiers. (Better not to use reserved words that way, but still . . .) MySQL isn't standard; it uses backticks. SQL Server uses square brackets.
You need to quote values.id.
SELECT "values".*
FROM "values"
JOIN taggings values_taggings_5183317
ON values_taggings_5183317.taggable_id = "values".id
-- ^ ^
AND values_taggings_5183317.taggable_type = 'Value'
AND values_taggings_5183317.tag_id = 2

PG::ConnectionBad: PQconsumeInput() SSL error: internal error

When working on my app locally using thin and ssl (thin start --ssl), I randomly get this error message every 5/10 requests.
PG::ConnectionBad: PQconsumeInput() SSL error: internal error
Usually I relaunch the query and it goes well, but it is a pain to having to refresh and being constantly interupted by this not understandable bug.
Here is the full stacktrace:
PG::ConnectionBad: PQconsumeInput() SSL error: internal error
: SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Completed 500 Internal Server Error in 3.6ms
ActiveRecord::StatementInvalid - PG::ConnectionBad: PQconsumeInput() SSL error: internal error
: SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1:
activerecord (3.2.18) lib/active_record/connection_adapters/abstract_adapter.rb:285:in `rescue in log'
activerecord (3.2.18) lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
activerecord (3.2.18) lib/active_record/connection_adapters/postgresql_adapter.rb:659:in `exec_query'
activerecord (3.2.18) lib/active_record/connection_adapters/postgresql_adapter.rb:1262:in `select'
activerecord (3.2.18) lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all'
activerecord (3.2.18) lib/active_record/connection_adapters/abstract/query_cache.rb:61:in `block in select_all'
activerecord (3.2.18) lib/active_record/connection_adapters/abstract/query_cache.rb:75:in `cache_sql'
activerecord (3.2.18) lib/active_record/connection_adapters/abstract/query_cache.rb:61:in `select_all'
activerecord (3.2.18) lib/active_record/querying.rb:38:in `block in find_by_sql'
activerecord (3.2.18) lib/active_record/explain.rb:41:in `logging_query_plan'
activerecord (3.2.18) lib/active_record/querying.rb:37:in `find_by_sql'
activerecord (3.2.18) lib/active_record/relation.rb:171:in `exec_queries'
activerecord (3.2.18) lib/active_record/relation.rb:160:in `block in to_a'
activerecord (3.2.18) lib/active_record/explain.rb:34:in `logging_query_plan'
activerecord (3.2.18) lib/active_record/relation.rb:159:in `to_a'
bullet (4.9.0) lib/bullet/active_record3x.rb:10:in `to_a'
activerecord (3.2.18) lib/active_record/relation/finder_methods.rb:381:in `find_first'
activerecord (3.2.18) lib/active_record/relation/finder_methods.rb:122:in `first'
orm_adapter (0.5.0) lib/orm_adapter/adapters/active_record.rb:17:in `get'
devise (3.2.4) lib/devise/models/authenticatable.rb:208:in `serialize_from_session'
devise (3.2.4) lib/devise.rb:462:in `block (2 levels) in configure_warden!'
warden (1.2.3) lib/warden/session_serializer.rb:34: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'
devise (3.2.4) lib/devise/controllers/helpers.rb:58:in `current_copasser'
devise (3.2.4) lib/devise/controllers/helpers.rb:54:in `copasser_signed_in?'
app/controllers/application_controller.rb:62:in `init_current_user'
activesupport (3.2.18) lib/active_support/callbacks.rb:418:in `_run__685085315745422875__process_action__3032562076037965401__callbacks'
activesupport (3.2.18) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.18) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.18) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.18) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.18) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.18) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.18) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.18) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.18) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.18) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.18) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.18) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.18) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.18) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.18) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.18) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.18) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.18) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.18) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.18) lib/action_dispatch/routing/route_set.rb:608:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/builder.rb:59:in `call'
bullet (4.9.0) lib/bullet/rack.rb:12: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 `call'
actionpack (3.2.18) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.5) lib/rack/etag.rb:23:in `call'
rack (1.4.5) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.18) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.18) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.18) lib/active_support/callbacks.rb:405:in `_run__2485068248532510814__call__1362848814740728564__callbacks'
activesupport (3.2.18) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.18) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.18) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.18) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
better_errors (1.1.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (1.1.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (1.1.0) lib/better_errors/middleware.rb:56:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.18) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.18) lib/rails/rack/logger.rb:18:in `call'
config/initializers/quiet_assets.rb:7:in `call_with_quiet_assets'
actionpack (3.2.18) 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.18) 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.18) lib/action_dispatch/middleware/static.rb:63:in `call'
font_assets (0.1.11) lib/font_assets/middleware.rb:29:in `call'
rack-ssl (1.3.4) lib/rack/ssl.rb:27:in `call'
railties (3.2.18) lib/rails/engine.rb:484:in `call'
railties (3.2.18) lib/rails/application.rb:231:in `call'
railties (3.2.18) lib/rails/railtie/configurable.rb:30:in `method_missing'
thin (1.6.2) lib/thin/connection.rb:86:in `block in pre_process'
thin (1.6.2) lib/thin/connection.rb:84:in `pre_process'
thin (1.6.2) lib/thin/connection.rb:53:in `process'
thin (1.6.2) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
thin (1.6.2) lib/thin/backends/base.rb:73:in `start'
thin (1.6.2) lib/thin/server.rb:162:in `start'
thin (1.6.2) lib/thin/controllers/controller.rb:87:in `start'
thin (1.6.2) lib/thin/runner.rb:199:in `run_command'
thin (1.6.2) lib/thin/runner.rb:155:in `run!'
thin (1.6.2) bin/thin:6:in `<top (required)>'
() home/augustin/.rvm/gems/ruby-1.9.3-p545/bin/thin:23:in `<main>'
() home/augustin/.rvm/gems/ruby-1.9.3-p545/bin/ruby_executable_hooks:15:in `<main>'
() home/augustin/.rvm/gems/ruby-1.9.3-p545/bin/ruby_executable_hooks:0:in `<main>'
I found this issue but it still remains unsolved.
Any clue on what I should do?
Thanks god it doesn't happen in production, not even in staging, only locally.
I'm using:
thin --version
thin 1.6.2 codename Doc Brown
rails --version
Rails 3.2.18
ruby --version
ruby 1.9.3p545 (2014-02-24 revision 45159) [x86_64-linux]
psql --version
psql (PostgreSQL) 9.1.13
Thanks in advance
I've been having the same problem for a few weeks now, today out of a hunch I added a pool: 1 in to the relevant section of my config/database.yml and now the error seems to have gone away.
Basically were are asking rails to not do connection pooling I in this case.
development:
adapter: postgresql
host: ec2-54-83-14-68.compute-1.amazonaws.com
username: rxeabczdnbhabc
password: hiddenZFYd1Mv-abEE9jhidden
database: d93f8pheuqtni3
pool: 1

Rails suddenly Giving me the following error

I am trying to do is when I click on view on the free page which is associated to list of companies and which should be asking me login but still I could able to do. Now it caused me an another problem after logged in when I click on the view of my list of companies it is showing me the following error.
I don't know which is causing the error. Can any one tell me what was the error and how to solve it.
And I don't have any method called login_required which I have before but I commented it.
Error is
Started GET "/company_ratings/user_rating?company_id=3" for 127.0.0.1 at 2014-01-22 10:11:34 +0100
Processing by CompanyRatingsController#user_rating as */*
Parameters: {"company_id"=>"3"}
Completed 500 Internal Server Error in 5ms
NameError (undefined local variable or method `login_required' for #<CompanyRatingsController:0x007f0c58948638>):
activesupport (4.0.2) lib/active_support/callbacks.rb:417:in `_run__2756769731211350067__process_action__callbacks'
activesupport (4.0.2) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.2) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (4.0.2) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.0.2) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (4.0.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.0.2) lib/abstract_controller/base.rb:136:in `process'
actionpack (4.0.2) lib/abstract_controller/rendering.rb:44:in `process'
actionpack (4.0.2) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.0.2) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.0.2) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.0.2) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.0.2) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.0.2) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:680: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:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.0.2) 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.2) lib/action_dispatch/middleware/cookies.rb:486:in `call'
activerecord (4.0.2) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
activerecord (4.0.2) lib/active_record/migration.rb:369:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.2) lib/active_support/callbacks.rb:373:in `_run__4080584768372332668__call__callbacks'
activesupport (4.0.2) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/reloader.rb:64:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.2) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.2) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.0.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.0.2) 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.2) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.0.2) lib/rails/engine.rb:511:in `call'
railties (4.0.2) 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'
/home/seshendra/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
/home/seshendra/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
/home/seshendra/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
Rendered /home/seshendra/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.7ms)
Rendered /home/seshendra/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.3ms)
Rendered /home/seshendra/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.2ms)
Rendered /home/seshendra/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (18.0ms)
It looks that you are calling, the now extinct, login_required method from a before_action callback in one of your controllers.
Either you should remove the callback, or reinstate your method.

Ruby on Rails with Sql Server (incompatible character encodings: UTF-8 and ASCII-8BIT)

is there any way to assign the string encoding to UTF-8 in Ruby On Rails 3?
Database Server: Windows Server 2008 R2
PC: Debian Squeeze.
I use Sql Server 2008 with ODBC and found (config/database.yml):
development:
adapter: sqlserver
host: 192.168.0.13\SQLDEVELOPMENT
mode: odbc
dsn: development
database: railsDev
username: developerRails
password: secret
encoding: utf8
gemfile:
...
gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter'
freetds.cfg:
[global]
tds version = 4.2
[development]
host = 192.168.0.13
port = 3341
intance = SQLDEVELOPMENT
tds version = 8.0
My problem is this:
incompatible character encodings: UTF-8 and ASCII-8BIT
Extracted source (around line #28):
26: <td><%= machine.id_maq %></td>
27: <td><%= machine.cod_maq %></td>
28: <td><%= machine.eqp_maq %></td> <!-- string -->
29: <td><%= machine.mar_maq %></td>
30: <td><%= machine.mod_maq %></td>
31: <td><%= machine.ser_maq %></td>
Full trace:
activesupport (3.2.13) lib/active_support/core_ext/string/output_safety.rb:135:in `concat'
activesupport (3.2.13) lib/active_support/core_ext/string/output_safety.rb:135:in `concat'
actionpack (3.2.13) lib/action_view/buffers.rb:11:in `<<'
app/views/machines/index.html.erb:28:in `block in _app_views_machines_index_html_erb__522342465_91242820'
app/views/machines/index.html.erb:23:in `each'
app/views/machines/index.html.erb:23:in `_app_views_machines_index_html_erb__522342465_91242820'
actionpack (3.2.13) lib/action_view/template.rb:145:in `block in render'
activesupport (3.2.13) lib/active_support/notifications.rb:125:in `instrument'
actionpack (3.2.13) lib/action_view/template.rb:143:in `render'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template'
actionpack (3.2.13) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.13) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:46:in `block in render_template'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:54:in `render_with_layout'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:45:in `render_template'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:18:in `render'
actionpack (3.2.13) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.2.13) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:110:in `_render_template'
actionpack (3.2.13) lib/action_controller/metal/streaming.rb:225:in `_render_template'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:103:in `render_to_body'
actionpack (3.2.13) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
actionpack (3.2.13) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:88:in `render'
actionpack (3.2.13) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.2.13) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/home/fhidalgo/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
activesupport (3.2.13) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:39:in `render'
actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (3.2.13) lib/action_controller/metal/mime_responds.rb:196:in `respond_to'
app/controllers/machines_controller.rb:8:in `index'
actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.13) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.13) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.13) lib/active_support/callbacks.rb:414:in `_run__557110257__process_action__673728653__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.13) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.13) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.13) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.13) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.5) lib/rack/etag.rb:23:in `call'
rack (1.4.5) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.13) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `_run__680852545__call__737805886__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.13) 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.13) 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.13) lib/action_dispatch/middleware/static.rb:63:in `call'
railties (3.2.13) lib/rails/engine.rb:479:in `call'
railties (3.2.13) lib/rails/application.rb:223:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.13) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
/home/fhidalgo/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
/home/fhidalgo/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
/home/fhidalgo/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
This does not help me at all.
I put this: 28: <td><%= machine.eqp_maq.force_encoding("UTF-8") %></td> and works, but I need this throughout the project.
I need to force the strings encoding to UTF-8, is possible?
Please don't use the old 'odbc' connection mode.
When using TinyTds you should use the 'dblib' mode:
development:
adapter: sqlserver
mode: dblib
host: 192.168.0.13\SQLDEVELOPMENT
database: railsDev
username: developerRails
password: secret
See also: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Using-TinyTds
Make sure all your views, specially the ones that are going to deploy UFT-8 characters are encoded in UTF-8. I solved a similar problem with MySQL that way
I was able to fix the error as follows:
In application.html.erb:
<div class="body">
<%= yield.force_encoding("UTF-8") %>
</div>
Not think it is the best solution but it works.

delayed_job: undefined method `name' for nil:NilClass

I just installed delayed job on my little Rails 3.2 app. Here is the controller where I use it:
require 'waveform'
class MixesController < ApplicationController
def index
end
def new
#mix = Mix.new
end
def create
#mix = Mix.new(params[:mix])
if #mix.save
options = {
method: :rms,
width: 1800,
height: 280,
background_color: "#ffffff",
color: "#3333ff",
force: true,
quiet: true
}
waveform = "./public/waveforms/#{File.basename(#mix.sound_file.to_s, File.extname(#mix.sound_file.to_s))}.png"
::Waveform.new("./public" + #mix.sound_file.to_s, nil).delay.generate(waveform, options)
flash[:success] = "Mix successfully uploaded"
redirect_to mix_url(#mix)
else
render :new
end
end
def show
#mix = Mix.find(params[:id])
end
end
I get an error saying: undefined methodname' for nil:NilClass`, here is the full stack trace:
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:25:in `block in initialize'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `yield'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `default'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `block in initialize'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `yield'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `default'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `block in initialize'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `yield'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `default'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `block in initialize'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `yield'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `default'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `block in initialize'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:102:in `yield'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:102:in `default'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:102:in `accept'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:447:in `block in dump_ivars'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:445:in `each'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:445:in `dump_ivars'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:124:in `visit_Object'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:102:in `accept'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:434:in `block in emit_coder'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:432:in `each'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:432:in `emit_coder'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:417:in `dump_coder'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:100:in `accept'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:66:in `push'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych.rb:242:in `dump'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/core_ext.rb:14:in `psych_to_yaml'
delayed_job (3.0.3) lib/delayed/backend/base.rb:80:in `payload_object='
activerecord (3.2.3) lib/active_record/attribute_assignment.rb:85:in `block in assign_attributes'
activerecord (3.2.3) lib/active_record/attribute_assignment.rb:78:in `each'
activerecord (3.2.3) lib/active_record/attribute_assignment.rb:78:in `assign_attributes'
activerecord (3.2.3) lib/active_record/base.rb:498:in `initialize'
delayed_job (3.0.3) lib/delayed/backend/base.rb:28:in `new'
delayed_job (3.0.3) lib/delayed/backend/base.rb:28:in `enqueue'
delayed_job (3.0.3) lib/delayed/message_sending.rb:13:in `method_missing'
app/controllers/mixes_controller.rb:25:in `create'
actionpack (3.2.3) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.3) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.3) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.3) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.3) lib/active_support/callbacks.rb:414:in `_run__842168672059661955__process_action__4066633601342968686__callbacks'
activesupport (3.2.3) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.3) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.3) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.3) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.3) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.3) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.3) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.3) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.3) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.3) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.3) lib/action_controller/metal/params_wrapper.rb:205:in `process_action'
activerecord (3.2.3) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.3) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.3) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.3) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.3) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.3) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.3) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.3) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.3) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.3) lib/journey/router.rb:68:in `block in call'
journey (1.0.3) lib/journey/router.rb:56:in `each'
journey (1.0.3) lib/journey/router.rb:56:in `call'
actionpack (3.2.3) lib/action_dispatch/routing/route_set.rb:600:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:35:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/cookies.rb:338:in `call'
activerecord (3.2.3) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:467:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.3) lib/active_support/callbacks.rb:405:in `_run__647780415925652457__call__1911592835196459847__callbacks'
activesupport (3.2.3) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.3) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.3) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.3) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:16: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/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/aziz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
Does anyone know why I am getting this error please?
This is happening because the system is trying to turn nil into a value that can be stored in YAML and is failing.
Looking at your code, I expect that is because you are passing a nil object into the variables passed to Waveform.new (the method whose operation is being delayed). The variables passed to new will need to be stored until delayed job is ready to run the process, and I expect they are stored as YAML.
Can you refactor Waveform to either make the second attribute optional (so its value doesn't have to be preserved)
::Waveform.new("./public" + #mix.sound_file.to_s).delay.generate(waveform, options)
or use something else to have the same meaning as nil. For example, pass in the symbol :none. Then the line becomes:
::Waveform.new("./public" + #mix.sound_file.to_s, :none).delay.generate(waveform, options)