I have a project on Rails 3.2. Also i used haml as my template engine but i decided to use slim instead of haml. So i rewrite some views using slim. But when i pushed this changes to server i got strange error in production.
The error appears ONLY on pages which use slim as a template engine. On my development machine pages open great. To setup server i used Rayan Byte's screencast
How can i fix that?
Error:
Started GET "/" for 128.69.76.116 at 2013-04-12 11:19:31 +0000
Started GET "/ru/articles" for 128.69.76.116 at 2013-04-12 11:19:31 +0000
Processing by ArticlesController#index as HTML
Parameters: {"locale"=>"ru"}
Completed 500 Internal Server Error in 180ms
ActionView::MissingTemplate (Missing template articles/index, application/index with {:locale=>[:ru], :formats=>[:html], :handlers=>[:erb, :builder, :haml]}. Searched in:
* "/home/deployer/apps/Chirch_app/releases/20130412101936/app/views"
* "/home/deployer/apps/Chirch_app/shared/bundle/ruby/1.9.1/gems/gmaps4rails-1.5.6/app/views"
* "/home/deployer/apps/Chirch_app/shared/bundle/ruby/1.9.1/gems/kaminari-0.14.0/app/views"
* "/home/deployer/apps/Chirch_app/shared/bundle/ruby/1.9.1/gems/devise-2.1.2/app/views"
):
actionpack (3.2.8) lib/action_view/path_set.rb:58:in `find'
actionpack (3.2.8) lib/action_view/lookup_context.rb:109:in `find'
actionpack (3.2.8) lib/action_view/renderer/abstract_renderer.rb:3:in `find_template'
actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:34:in `determine_template'
actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:10:in `render'
actionpack (3.2.8) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.2.8) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.2.8) lib/abstract_controller/rendering.rb:110:in `_render_template'
actionpack (3.2.8) lib/action_controller/metal/streaming.rb:225:in `_render_template'
actionpack (3.2.8) lib/abstract_controller/rendering.rb:103:in `render_to_body'
actionpack (3.2.8) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
actionpack (3.2.8) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
actionpack (3.2.8) lib/abstract_controller/rendering.rb:88:in `render'
actionpack (3.2.8) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.2.8) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/home/deployer/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
activesupport (3.2.8) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
activerecord (3.2.8) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:39:in `render'
actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (3.2.8) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.8) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.8) lib/active_support/callbacks.rb:436:in `_run__609582508__process_action__934117167__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.8) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.8) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.8) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.8) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.8) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.8) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.8) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.8) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.8) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.8) 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.8) lib/action_dispatch/routing/route_set.rb:600: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.8) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.4) lib/rack/etag.rb:23:in `call'
rack (1.4.4) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.4) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.4) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/cookies.rb:339:in `call'
activerecord (3.2.8) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `_run__319658905__call__322020128__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.8) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.8) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.4) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.4) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.4) 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.8) lib/rails/engine.rb:479:in `call'
railties (3.2.8) lib/rails/application.rb:223:in `call'
railties (3.2.8) lib/rails/railtie/configurable.rb:30:in `method_missing'
unicorn (4.5.0) lib/unicorn/http_server.rb:552:in `process_client'
unicorn (4.5.0) lib/unicorn/http_server.rb:628:in `worker_loop'
unicorn (4.5.0) lib/unicorn/http_server.rb:500:in `spawn_missing_workers'
unicorn (4.5.0) lib/unicorn/http_server.rb:511:in `maintain_worker_count'
unicorn (4.5.0) lib/unicorn/http_server.rb:277:in `join'
unicorn (4.5.0) bin/unicorn:121:in `<top (required)>'
/home/deployer/apps/Chirch_app/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `load'
/home/deployer/apps/Chirch_app/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `<main>'
Gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'pg', '0.15.1'
gem 'jquery-rails', '2.2.1'
gem 'haml', '4.0.2'
gem 'therubyracer', :platform => :ruby
gem 'devise', '2.2.3'
gem 'simple_form', '2.1.0'
gem 'bootstrap-wysihtml5-rails', "0.3.1.19"
gem 'kaminari', '0.14.0'
gem "cancan", '1.6.9'
gem "carrierwave", '0.8.0'
gem "rmagick", '2.13.2'
gem 'gmaps4rails', '1.5.6'
gem 'unicorn', '4.6.2'
gem 'capistrano', '2.14.2'
gem 'less-rails', '2.3.2'
gem 'slim', '1.3.8'
gem 'haml2slim'
group :assets do
gem 'sass-rails', '~> 3.2.4'
gem 'coffee-rails', '~> 3.2.2'
gem 'twitter-bootstrap-rails', '2.2.6'
gem 'uglifier', '>= 1.2.3'
end
group :development do
gem 'annotate', '~> 2.5.0'
gem 'better_errors'
gem 'binding_of_caller'
gem 'brakeman'
gem 'meta_request'
end
group :development, :test do
gem 'rspec-rails', '2.13.0'
gem 'rb-fsevent'
gem 'guard-rspec', '2.5.2'
gem 'terminal-notifier-guard'
gem 'launchy'
end
group :test do
gem 'capybara', '2.1.0'
gem 'factory_girl_rails', '4.2.1'
gem 'database_cleaner', '0.9.1'
gem 'selenium-webdriver', '2.32.1'
end
I found the problem. After a long time of researching (unicorn and ngingx restarts didn't help) i just rebooted the whole Operating System and after that Slim page appeared.
Look at the error, the template handle is still haml
:formats=>[:html], :handlers=>[:erb, :builder, :haml]}
My guess is you index page includes some partial written in haml, thus brings the confuse. The local development machine may have some cache in browser thus no problem there.
How about your turn all haml template into slim, delete all haml templates(use git rm), remove haml gem from Gemfile, and try again?
Related
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
I've been working for the last two days (not long enough, it seems) to getting haml-rails to work with this RoR application. The backtrace I'm getting is this:
ActionView::MissingTemplate (Missing template customcare360/login, application/login with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder]}. Searched in:
* "/var/www/clients/client1/web54/capistrano/releases/20130403223833/app/views"
):
actionpack (3.2.11) lib/action_view/path_set.rb:58:in `find'
actionpack (3.2.11) lib/action_view/lookup_context.rb:109:in `find'
actionpack (3.2.11) lib/action_view/renderer/abstract_renderer.rb:3:in `find_template'
actionpack (3.2.11) lib/action_view/renderer/template_renderer.rb:34:in `determine_template'
actionpack (3.2.11) lib/action_view/renderer/template_renderer.rb:10:in `render'
actionpack (3.2.11) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.2.11) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.2.11) lib/abstract_controller/rendering.rb:110:in `_render_template'
actionpack (3.2.11) lib/action_controller/metal/streaming.rb:225:in `_render_template'
actionpack (3.2.11) lib/abstract_controller/rendering.rb:103:in `render_to_body'
actionpack (3.2.11) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
actionpack (3.2.11) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
actionpack (3.2.11) lib/abstract_controller/rendering.rb:88:in `render'
actionpack (3.2.11) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.2.11) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.2.11) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/usr/local/rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
activesupport (3.2.11) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.2.11) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.2.11) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
activerecord (3.2.11) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
actionpack (3.2.11) lib/action_controller/metal/instrumentation.rb:39:in `render'
actionpack (3.2.11) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (3.2.11) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (3.2.11) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.11) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.11) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.11) lib/active_support/callbacks.rb:414:in `_run__3579697130236064177__process_action__869676858511540114__callbacks'
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_process_action_callbacks'
activesupport (3.2.11) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.11) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.11) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.11) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.11) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.11) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.11) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.11) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.11) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.11) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.11) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.11) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.11) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.11) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.11) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.11) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.11) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.11) 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.11) lib/action_dispatch/routing/route_set.rb:601:in `call'
actionpack (3.2.11) 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.11) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.11) 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.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 `block in call'
activesupport (3.2.11) lib/active_support/callbacks.rb:405:in `_run__3196186370685956669__call__1689534214956595528__callbacks'
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 `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 `block 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.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.11) 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.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: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.11) lib/rails/engine.rb:479:in `call'
railties (3.2.11) lib/rails/application.rb:223:in `call'
railties (3.2.11) lib/rails/railtie/configurable.rb:30:in `method_missing'
unicorn (4.6.2) lib/unicorn/http_server.rb:552:in `process_client'
unicorn (4.6.2) lib/unicorn/http_server.rb:632:in `worker_loop'
unicorn (4.6.2) lib/unicorn/http_server.rb:500:in `spawn_missing_workers'
unicorn (4.6.2) lib/unicorn/http_server.rb:142:in `start'
unicorn (4.6.2) bin/unicorn:126:in `<top (required)>'
/var/www/ageless360-patient.theblsgroup.net/capistrano/shared/bundle/ruby/2.0.0/bin/unicorn:23:in `load'
/var/www/ageless360-patient.theblsgroup.net/capistrano/shared/bundle/ruby/2.0.0/bin/unicorn:23:in `<main>'
I've tried manually loading 'haml-rails' into my config/application.rb. My Gemfile looks like this:
source 'https://rubygems.org'
gem 'rails', '3.2.11'
# Environment-independent gems
gem 'mysql2'
gem 'json'
# Use unicorn as the app server
gem 'unicorn'
# HAML up the HTML.
gem 'haml'
gem 'haml-rails'
group :development do
# Provides an intuitve means of debugging in the browser.
gem 'better_errors'
# Remove unnecessary assets from being logged at dev time.
gem 'quiet_assets'
# Deploy with Capistrano
gem 'capistrano'
gem 'capistrano-ext'
gem 'capistrano-unicorn'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
gem 'jquery-rails'
end
I'm following through Railscast #235 "Devise + OmniAuth Revised" and have run into a NoMethodError for Username whenever I try to authenticate using Twitter. I'm running Rails 3.2.
Specifically, it reads:
NoMethodError in OmniauthCallbacksController#twitter
undefined method `username' for #<User:0x007fa4744561c0>
app/models/user.rb:11:in `from_omniauth'
app/controllers/omniauth_callbacks_controller.rb:3:in `all'
I'm new to Rails, so any help would be much appreciated. Here's a look at my code:
The omniauth_callbacks_controller:
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def all
user = User.from_omniauth(request.env["omniauth.auth"])
if user.persisted?
flash.notice = "Signed in!"
sign_in_and_redirect user
else
session["devise.user_attributes"] = user.attributes
redirect_to new_user_registration_url
end
end
alias_method :twitter, :all
end
The user model:
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :omniauthable,
:recoverable, :rememberable, :trackable, :validatable
attr_accessible :email, :password, :password_confirmation, :remember_me, :username
validates_presence_of :username
validates_uniqueness_of :username
def self.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_create do |user|
user.provider = auth.provider
user.uid = auth.uid
user.username = auth.info.nickname
end
end
def self.new_with_session(params, session)
if session["devise.user_attributes"]
new(session["devise.user_attributes"], without_protection: true) do |user|
user.attributes = params
user.valid?
end
else
super
end
end
def password_required?
super && provider.blank?
end
def update_with_password(params, *options)
if encrypted_password.blank?
update_attributes(params, *options)
else
super
end
end
end
Framework Trace:
activemodel (3.2.8) lib/active_model/attribute_methods.rb:407:in `method_missing'
activerecord (3.2.8) lib/active_record/attribute_methods.rb:149:in `method_missing'
activemodel (3.2.8) lib/active_model/errors.rb:254:in `block in add_on_blank'
activemodel (3.2.8) lib/active_model/errors.rb:253:in `each'
activemodel (3.2.8) lib/active_model/errors.rb:253:in `add_on_blank'
activemodel (3.2.8) lib/active_model/validations/presence.rb:8:in `validate'
activesupport (3.2.8) lib/active_support/callbacks.rb:310:in `_callback_before_35'
activesupport (3.2.8) lib/active_support/callbacks.rb:473:in `_run__3967236747236009763__validate__2888041296400006394__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_validate_callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
activemodel (3.2.8) lib/active_model/validations.rb:227:in `run_validations!'
activemodel (3.2.8) lib/active_model/validations/callbacks.rb:53:in `block in run_validations!'
activesupport (3.2.8) lib/active_support/callbacks.rb:425:in `_run__3967236747236009763__validation__2888041296400006394__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_validation_callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
activemodel (3.2.8) lib/active_model/validations/callbacks.rb:53:in `run_validations!'
activemodel (3.2.8) lib/active_model/validations.rb:194:in `valid?'
activerecord (3.2.8) lib/active_record/validations.rb:69:in `valid?'
activerecord (3.2.8) lib/active_record/validations.rb:77:in `perform_validations'
activerecord (3.2.8) lib/active_record/validations.rb:50:in `save'
activerecord (3.2.8) lib/active_record/attribute_methods/dirty.rb:22:in `save'
activerecord (3.2.8) lib/active_record/transactions.rb:241:in `block (2 levels) in save'
activerecord (3.2.8) lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
activerecord (3.2.8) lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
activerecord (3.2.8) lib/active_record/transactions.rb:208:in `transaction'
activerecord (3.2.8) lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
activerecord (3.2.8) lib/active_record/transactions.rb:241:in `block in save'
activerecord (3.2.8) lib/active_record/transactions.rb:252:in `rollback_active_record_state!'
activerecord (3.2.8) lib/active_record/transactions.rb:240:in `save'
activerecord (3.2.8) lib/active_record/persistence.rb:45:in `create'
activerecord (3.2.8) lib/active_record/relation.rb:87:in `block in create'
activerecord (3.2.8) lib/active_record/relation.rb:241:in `block in scoping'
activerecord (3.2.8) lib/active_record/scoping.rb:98:in `with_scope'
activerecord (3.2.8) lib/active_record/relation.rb:241:in `scoping'
activerecord (3.2.8) lib/active_record/relation.rb:87:in `create'
activerecord (3.2.8) lib/active_record/relation.rb:119:in `first_or_create'
actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.8) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.8) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.8) lib/active_support/callbacks.rb:436:in `_run__3199821227742357635__process_action__2555454004410598156__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.8) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.8) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.8) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.8) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.8) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.8) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.8) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.8) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.8) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:36:in `call'
actionpack (3.2.8) lib/action_dispatch/routing/mapper.rb:42: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.8) lib/action_dispatch/routing/route_set.rb:600:in `call'
omniauth (1.1.1) lib/omniauth/strategy.rb:394:in `call_app!'
omniauth (1.1.1) lib/omniauth/strategy.rb:356:in `callback_phase'
omniauth-oauth (1.0.1) lib/omniauth/strategies/oauth.rb:58:in `callback_phase'
omniauth (1.1.1) lib/omniauth/strategy.rb:219:in `callback_call'
omniauth (1.1.1) lib/omniauth/strategy.rb:175:in `call!'
omniauth (1.1.1) lib/omniauth/strategy.rb:157: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.8) 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:25:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.8) 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.8) lib/action_dispatch/middleware/cookies.rb:339:in `call'
activerecord (3.2.8) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `_run__635784344197953786__call__2888041296400006394__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.8) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.8) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.8) lib/rails/engine.rb:479:in `call'
railties (3.2.8) lib/rails/application.rb:223:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.8) lib/rails/rack/log_tailer.rb:17:in `call'
thin (1.4.1) lib/thin/connection.rb:80:in `block in pre_process'
thin (1.4.1) lib/thin/connection.rb:78:in `catch'
thin (1.4.1) lib/thin/connection.rb:78:in `pre_process'
thin (1.4.1) lib/thin/connection.rb:53:in `process'
thin (1.4.1) lib/thin/connection.rb:38:in `receive_data'
eventmachine (1.0.0) lib/eventmachine.rb:187:in `run_machine'
eventmachine (1.0.0) lib/eventmachine.rb:187:in `run'
thin (1.4.1) lib/thin/backends/base.rb:63:in `start'
thin (1.4.1) lib/thin/server.rb:159:in `start'
rack (1.4.1) lib/rack/handler/thin.rb:13:in `run'
rack (1.4.1) lib/rack/server.rb:265:in `start'
railties (3.2.8) lib/rails/commands/server.rb:70:in `start'
railties (3.2.8) lib/rails/commands.rb:55:in `block in <top (required)>'
railties (3.2.8) lib/rails/commands.rb:50:in `tap'
railties (3.2.8) lib/rails/commands.rb:50:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'
You need to add a username column to your users table.
I can't seem to get CanCan working. This has turned out to be quite frustrating, especially when I have followed the rule book and tried, seemingly, all the tricks under the sun to get it to work.
I am using Rails 3.1.2, Devise 2.1.2, and CanCan 1.6.8. I set-up a separate role model as described by RyanB here.
This is my code.
1) ability.rb
class Ability
include CanCan::Ability
def initializer(user)
user ||= User.new # For users with no account
if (user.has_role?(:admin)) || (user.has_role?(:mod))
can :manage, :all
elsif user.has_role?(:registered)
can :read, :all
can :create, :all
can :update, Question do |question|
question.try(:user) == (user || user.has_role?(:admin) || user.has_role?(:mod))
end
can :destroy, Question do |question|
question.try(:user) == (user || user.has_role?(:admin) || user.has_role?(:mod))
end
else
can :read, :all
end
end
end
2) has_role? definition in user.rb
def has_role?(role_sym)
roles.any? { |r| r.name.underscore.to_sym == role_sym }
end
3) Controller before filters
before_filter :authenticate_user!, :except => :show
load_and_authorize_resource
skip_authorize_resource :only => :show
Authorizing any controller with CanCan results in the same error on all actions.
EDIT: Stack Trace
cancan (1.6.8) lib/cancan/controller_additions.rb:352:in `initialize'
cancan (1.6.8) lib/cancan/controller_additions.rb:352:in `new'
cancan (1.6.8) lib/cancan/controller_additions.rb:352:in `current_ability'
cancan (1.6.8) lib/cancan/controller_resource.rb:207:in `current_ability'
cancan (1.6.8) lib/cancan/controller_resource.rb:77:in `load_collection?'
cancan (1.6.8) lib/cancan/controller_resource.rb:33:in `load_resource'
cancan (1.6.8) lib/cancan/controller_resource.rb:25:in `load_and_authorize_resource'
cancan (1.6.8) lib/cancan/controller_resource.rb:10:in `block in add_before_filter'
activesupport (3.2.1) lib/active_support/callbacks.rb:429:in `_run__458654864__process_action__156152648__callbacks'
activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.1) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.1) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.1) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.1) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.1) lib/action_controller/metal/params_wrapper.rb:205:in `process_action'
activerecord (3.2.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.1) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.1) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.1) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.1) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.1) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:66:in `call'
actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:66:in `dispatch'
actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:30: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.1) lib/action_dispatch/routing/route_set.rb:589: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.1) 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:25:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.1) 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.1) lib/action_dispatch/middleware/cookies.rb:338:in `call'
activerecord (3.2.1) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `_run__446710069__call__461654473__callbacks'
activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.1) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.1) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.1) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.1) 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.1) 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.1) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.2.1) lib/rails/engine.rb:479:in `call'
railties (3.2.1) lib/rails/application.rb:220:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.1) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/home/administrator/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/home/administrator/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/home/administrator/.rvm/rubies/ruby-1
.9.3-p125/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
Okay, it seems, I did not followed ALL the rules of the rule book. Although I cannot see how this could be a problem. To get this working, I deleted my ability.rb file that I created manually, and used the rails g cancan:ability command to generate the same file in the same directory, and used the same code. And now it works like a charm.
using Rails 3 I can't get a form with with ActiveMerchant::Billing::CreditCard.new working as expected.
controller
#credit_card = ActiveMerchant::Billing::CreditCard.new
view
<%= form_for :credit_card, #credit_card do |f| %>
<%= f.text_field :first_name %>
<% end %>
Error
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.any?
actionpack (3.0.4) lib/action_view/helpers/active_model_helper.rb:62:in `object_has_errors?'
actionpack (3.0.4) lib/action_view/helpers/active_model_helper.rb:48:in `error_wrapping'
actionpack (3.0.4) lib/action_view/helpers/active_model_helper.rb:44:in `tag'
actionpack (3.0.4) lib/action_view/helpers/form_helper.rb:918:in `to_input_field_tag'
actionpack (3.0.4) lib/action_view/helpers/form_helper.rb:625:in `text_field'
actionpack (3.0.4) lib/action_view/helpers/form_helper.rb:1131:in `send'
actionpack (3.0.4) lib/action_view/helpers/form_helper.rb:1131:in `text_field'
app/views/account/credit_card/edit.html.erb:8:in `_app_views_account_credit_card_edit_html_erb___109645858_2193109920_0'
actionpack (3.0.4) lib/action_view/helpers/capture_helper.rb:40:in `capture'
actionpack (3.0.4) lib/action_view/helpers/capture_helper.rb:172:in `with_output_buffer'
actionpack (3.0.4) lib/action_view/helpers/capture_helper.rb:40:in `capture'
actionpack (3.0.4) lib/action_view/helpers/form_helper.rb:544:in `fields_for'
actionpack (3.0.4) lib/action_view/helpers/form_helper.rb:320:in `form_for'
app/views/account/credit_card/edit.html.erb:7:in `_app_views_account_credit_card_edit_html_erb___109645858_2193109920_0'
actionpack (3.0.4) lib/action_view/template.rb:135:in `send'
actionpack (3.0.4) lib/action_view/template.rb:135:in `render'
activesupport (3.0.4) lib/active_support/notifications.rb:54:in `instrument'
actionpack (3.0.4) lib/action_view/template.rb:127:in `render'
actionpack (3.0.4) lib/action_view/render/rendering.rb:59:in `_render_template'
activesupport (3.0.4) lib/active_support/notifications.rb:52:in `instrument'
activesupport (3.0.4) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.4) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.4) lib/action_view/render/rendering.rb:56:in `_render_template'
actionpack (3.0.4) lib/action_view/render/rendering.rb:26:in `render'
actionpack (3.0.4) lib/abstract_controller/rendering.rb:115:in `_render_template'
actionpack (3.0.4) lib/abstract_controller/rendering.rb:109:in `render_to_body'
actionpack (3.0.4) lib/action_controller/metal/renderers.rb:47:in `render_to_body'
actionpack (3.0.4) lib/action_controller/metal/compatibility.rb:55:in `render_to_body'
actionpack (3.0.4) lib/abstract_controller/rendering.rb:102:in `render_to_string'
actionpack (3.0.4) lib/abstract_controller/rendering.rb:93:in `render'
actionpack (3.0.4) lib/action_controller/metal/rendering.rb:17:in `render'
actionpack (3.0.4) lib/action_controller/metal/instrumentation.rb:40:in `render_without_wicked_pdf'
activesupport (3.0.4) lib/active_support/core_ext/benchmark.rb:5:in `ms'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
activesupport (3.0.4) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.0.4) lib/action_controller/metal/instrumentation.rb:40:in `render_without_wicked_pdf'
actionpack (3.0.4) lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
activerecord (3.0.4) lib/active_record/railties/controller_runtime.rb:15:in `cleanup_view_runtime'
actionpack (3.0.4) lib/action_controller/metal/instrumentation.rb:39:in `render_without_wicked_pdf'
vendor/plugins/wicked_pdf/lib/pdf_helper.rb:15:in `render'
actionpack (3.0.4) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (3.0.4) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (3.0.4) lib/abstract_controller/base.rb:150:in `process_action'
actionpack (3.0.4) lib/action_controller/metal/rendering.rb:11:in `process_action'
actionpack (3.0.4) lib/abstract_controller/callbacks.rb:18:in `process_action'
activesupport (3.0.4) lib/active_support/callbacks.rb:485:in `_run__210577272__process_action__1992409046__callbacks'
activesupport (3.0.4) lib/active_support/callbacks.rb:409:in `send'
activesupport (3.0.4) lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'
activesupport (3.0.4) lib/active_support/callbacks.rb:93:in `send'
activesupport (3.0.4) lib/active_support/callbacks.rb:93:in `run_callbacks'
actionpack (3.0.4) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.0.4) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
activesupport (3.0.4) lib/active_support/notifications.rb:52:in `instrument'
activesupport (3.0.4) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.4) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.4) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.0.4) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.0.4) lib/abstract_controller/base.rb:119:in `process'
actionpack (3.0.4) lib/abstract_controller/rendering.rb:41:in `process'
actionpack (3.0.4) lib/action_controller/metal.rb:138:in `dispatch'
actionpack (3.0.4) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.0.4) lib/action_controller/metal.rb:178:in `action'
actionpack (3.0.4) lib/action_dispatch/routing/route_set.rb:62:in `call'
actionpack (3.0.4) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
actionpack (3.0.4) lib/action_dispatch/routing/route_set.rb:27:in `call'
rack-mount (0.6.13) lib/rack/mount/route_set.rb:148:in `call'
routing-filter (0.2.3) lib/routing_filter/adapters/rails_3.rb:74:in `recognize'
rack-mount (0.6.13) lib/rack/mount/route_set.rb:139:in `call'
actionpack (3.0.4) lib/action_dispatch/routing/route_set.rb:492:in `call'
exception_notification_rails3 (1.2.0) lib/exception_notifier.rb:34:in `call'
warden (1.0.3) lib/warden/manager.rb:35:in `call'
warden (1.0.3) lib/warden/manager.rb:34:in `catch'
warden (1.0.3) lib/warden/manager.rb:34:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.1) lib/rack/methodoverride.rb:24:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/flash.rb:182:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/cookies.rb:302:in `call'
activerecord (3.0.4) lib/active_record/query_cache.rb:32:in `call'
activerecord (3.0.4) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
activerecord (3.0.4) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.4) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/callbacks.rb:46:in `call'
activesupport (3.0.4) lib/active_support/callbacks.rb:415:in `_run_call_callbacks'
actionpack (3.0.4) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.1) lib/rack/sendfile.rb:107:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.0.4) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.4) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.1) lib/rack/lock.rb:11:in `call'
rack (1.2.1) lib/rack/lock.rb:11:in `synchronize'
rack (1.2.1) lib/rack/lock.rb:11:in `call'
actionpack (3.0.4) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.4) lib/rails/application.rb:168:in `call'
railties (3.0.4) lib/rails/application.rb:77:in `send'
railties (3.0.4) lib/rails/application.rb:77:in `method_missing'
passenger (3.0.2) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
passenger (3.0.2) lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
passenger (3.0.2) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
passenger (3.0.2) lib/phusion_passenger/rack/application_spawner.rb:205:in `start_request_handler'
passenger (3.0.2) lib/phusion_passenger/rack/application_spawner.rb:170:in `send'
passenger (3.0.2) lib/phusion_passenger/rack/application_spawner.rb:170:in `handle_spawn_application'
passenger (3.0.2) lib/phusion_passenger/utils.rb:479:in `safe_fork'
passenger (3.0.2) lib/phusion_passenger/rack/application_spawner.rb:165:in `handle_spawn_application'
passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:180:in `start'
passenger (3.0.2) lib/phusion_passenger/rack/application_spawner.rb:128:in `start'
passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:253:in `spawn_rack_application'
passenger (3.0.2) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:246:in `spawn_rack_application'
passenger (3.0.2) lib/phusion_passenger/abstract_server_collection.rb:82:in `synchronize'
passenger (3.0.2) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.2) helper-scripts/passenger-spawn-server:99
I do not use any form builder while getting this error. Is there a different way to do this ?
You can hack your way through this:
https://github.com/Shopify/active_merchant/pull/33
Shopify team says fix won't be in until ActiveMerchant 2.0