"No method error" from tests in Rails using Capybara - ruby-on-rails

I have a simple test written using RSpec and Capybara.
My failing spec is sign_in_feature_spec.rb:
require 'spec_helper'
describe 'the signin process', :type => :feature do
it 'signs me in' do
admin_user = FactoryGirl.create(:admin_user)
login_as(admin_user, :scope => :admin_user)
visit root_path
puts page.body
end
end
When I run this spec, I see next report:
1 example, 0 failures, 1 passed
So, the test was successful, but I get this output from puts page.body:
NoMethodError at /
==================
> undefined method `saved_filters' for #<AdminUser:0x00000009abf870>
activemodel (4.1.9) lib/active_model/attribute_methods.rb, line 435
-------------------------------------------------------------------
``` ruby
430 def method_missing(method, *args, &block)
431 if respond_to_without_attributes?(method, true)
432 super
433 else
434 match = match_attribute_method?(method.to_s)
> 435 match ? attribute_missing(match, *args, &block) : super
436 end
437 end
438
439 # +attribute_missing+ is like +method_missing+, but for attributes. When
440 # +method_missing+ is called we check to see if there is a matching
```
App backtrace
-------------
- activemodel (4.1.9) lib/active_model/attribute_methods.rb:435:in `method_missing'
- activerecord (4.1.9) lib/active_record/attribute_methods.rb:213:in `method_missing'
- lib/active_admin/filter_saver/controller.rb:35:in `save_filters?'
- config/initializers/active_admin.rb:165:in `block (2 levels) in <top (required)>'
- activesupport (4.1.9) lib/active_support/callbacks.rb:438:in `block in make_lambda'
- activesupport (4.1.9) lib/active_support/callbacks.rb:143:in `block in halting_and_conditional'
- activesupport (4.1.9) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:229:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:86:in `run_callbacks'
- actionpack (4.1.9) lib/abstract_controller/callbacks.rb:19:in `process_action'
- actionpack (4.1.9) lib/action_controller/metal/rescue.rb:29:in `process_action'
- config/initializers/instrumentation_notification.rb:28:in `block in process_action'
- activesupport (4.1.9) lib/active_support/notifications.rb:159:in `block in instrument'
- activesupport (4.1.9) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
- activesupport (4.1.9) lib/active_support/notifications.rb:159:in `instrument'
- config/initializers/instrumentation_notification.rb:27:in `process_action'
- actionpack (4.1.9) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
- activerecord (4.1.9) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
- actionpack (4.1.9) lib/abstract_controller/base.rb:136:in `process'
- actionview (4.1.9) lib/action_view/rendering.rb:30:in `process'
- actionpack (4.1.9) lib/action_controller/metal.rb:196:in `dispatch'
- actionpack (4.1.9) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
- actionpack (4.1.9) lib/action_controller/metal.rb:232:in `block in action'
- actionpack (4.1.9) lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
- actionpack (4.1.9) lib/action_dispatch/routing/route_set.rb:50:in `call'
- actionpack (4.1.9) lib/action_dispatch/journey/router.rb:73:in `block in call'
- actionpack (4.1.9) lib/action_dispatch/journey/router.rb:59:in `call'
- actionpack (4.1.9) lib/action_dispatch/routing/route_set.rb:685: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'
- rack (1.5.5) lib/rack/etag.rb:23:in `call'
- rack (1.5.5) lib/rack/conditionalget.rb:25:in `call'
- rack (1.5.5) lib/rack/head.rb:11:in `call'
- actionpack (4.1.9) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
- actionpack (4.1.9) lib/action_dispatch/middleware/flash.rb:254:in `call'
- rack (1.5.5) lib/rack/session/abstract/id.rb:225:in `context'
- rack (1.5.5) lib/rack/session/abstract/id.rb:220:in `call'
- actionpack (4.1.9) lib/action_dispatch/middleware/cookies.rb:562:in `call'
- activerecord (4.1.9) lib/active_record/query_cache.rb:36:in `call'
- activerecord (4.1.9) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
- actionpack (4.1.9) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
- activesupport (4.1.9) lib/active_support/callbacks.rb:82:in `run_callbacks'
- actionpack (4.1.9) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
- actionpack (4.1.9) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
- better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
- better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
- better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
- actionpack (4.1.9) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
- actionpack (4.1.9) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
- railties (4.1.9) lib/rails/rack/logger.rb:38:in `call_app'
- railties (4.1.9) lib/rails/rack/logger.rb:20:in `block in call'
- activesupport (4.1.9) lib/active_support/tagged_logging.rb:68:in `block in tagged'
- activesupport (4.1.9) lib/active_support/tagged_logging.rb:26:in `tagged'
- activesupport (4.1.9) lib/active_support/tagged_logging.rb:68:in `tagged'
- railties (4.1.9) lib/rails/rack/logger.rb:20:in `call'
- request_store (1.1.0) lib/request_store/middleware.rb:8:in `call'
- actionpack (4.1.9) lib/action_dispatch/middleware/request_id.rb:21:in `call'
- rack (1.5.5) lib/rack/methodoverride.rb:21:in `call'
- rack (1.5.5) lib/rack/runtime.rb:17:in `call'
- activesupport (4.1.9) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
- actionpack (4.1.9) lib/action_dispatch/middleware/static.rb:84:in `call'
- rack (1.5.5) lib/rack/sendfile.rb:112:in `call'
- railties (4.1.9) lib/rails/engine.rb:514:in `call'
- railties (4.1.9) lib/rails/application.rb:144:in `call'
- rack (1.5.5) lib/rack/builder.rb:138:in `call'
- rack (1.5.5) lib/rack/urlmap.rb:65:in `block in call'
- rack (1.5.5) lib/rack/urlmap.rb:50:in `call'
- rack-test (0.6.3) lib/rack/mock_session.rb:30:in `request'
- rack-test (0.6.3) lib/rack/test.rb:244:in `process_request'
- rack-test (0.6.3) lib/rack/test.rb:58:in `get'
- capybara (2.5.0) lib/capybara/rack_test/browser.rb:60:in `process'
- capybara (2.5.0) lib/capybara/rack_test/browser.rb:35:in `process_and_follow_redirects'
- capybara (2.5.0) lib/capybara/rack_test/browser.rb:21:in `visit'
- capybara (2.5.0) lib/capybara/rack_test/driver.rb:42:in `visit'
- capybara (2.5.0) lib/capybara/session.rb:232:in `visit'
- capybara (2.5.0) lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
- rspec-rails (3.2.0) lib/rspec/rails/example/feature_example_group.rb:28:in `visit'
- spec/features/sign_in_feature_spec.rb:7:in `block (2 levels) in <top (required)>'
- rspec-core (3.2.0) lib/rspec/core/example.rb:177:in `block in run'
- rspec-core (3.2.0) lib/rspec/core/example.rb:385:in `block in with_around_and_singleton_context_hooks'
- rspec-core (3.2.0) lib/rspec/core/example.rb:343:in `block in with_around_example_hooks'
- rspec-core (3.2.0) lib/rspec/core/hooks.rb:474:in `block in run'
- rspec-core (3.2.0) lib/rspec/core/hooks.rb:614:in `block in run_around_example_hooks_for'
- rspec-core (3.2.0) lib/rspec/core/example.rb:247:in `call'
- rspec-rails (3.2.0) lib/rspec/rails/adapters.rb:111:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
- rspec-core (3.2.0) lib/rspec/core/example.rb:333:in `instance_exec'
- rspec-core (3.2.0) lib/rspec/core/hooks.rb:387:in `execute_with'
- rspec-core (3.2.0) lib/rspec/core/hooks.rb:616:in `block (2 levels) in run_around_example_hooks_for'
- rspec-core (3.2.0) lib/rspec/core/example.rb:247:in `call'
- rspec-core (3.2.0) lib/rspec/core/hooks.rb:617:in `run_around_example_hooks_for'
- rspec-core (3.2.0) lib/rspec/core/hooks.rb:474:in `run'
- rspec-core (3.2.0) lib/rspec/core/example.rb:343:in `with_around_example_hooks'
- rspec-core (3.2.0) lib/rspec/core/example.rb:385:in `with_around_and_singleton_context_hooks'
- rspec-core (3.2.0) lib/rspec/core/example.rb:174:in `run'
- rspec-core (3.2.0) lib/rspec/core/example_group.rb:548:in `block in run_examples'
- rspec-core (3.2.0) lib/rspec/core/example_group.rb:544:in `run_examples'
- rspec-core (3.2.0) lib/rspec/core/example_group.rb:512:in `run'
- rspec-core (3.2.0) lib/rspec/core/runner.rb:110:in `block (3 levels) in run_specs'
- rspec-core (3.2.0) lib/rspec/core/runner.rb:110:in `block (2 levels) in run_specs'
- rspec-core (3.2.0) lib/rspec/core/configuration.rb:1526:in `with_suite_hooks'
- rspec-core (3.2.0) lib/rspec/core/runner.rb:109:in `block in run_specs'
- rspec-core (3.2.0) lib/rspec/core/reporter.rb:62:in `report'
- rspec-core (3.2.0) lib/rspec/core/runner.rb:108:in `run_specs'
- rspec-core (3.2.0) lib/rspec/core/runner.rb:86:in `run'
- rspec-core (3.2.0) lib/rspec/core/runner.rb:70:in `run'
- rspec-core (3.2.0) lib/rspec/core/runner.rb:38:in `invoke'
- rspec-core (3.2.0) exe/rspec:4:in `<top (required)>'
- ruby/2.1.0/bin/rspec:23:in `<top (required)>'
Full backtrace
--------------
- activemodel (4.1.9) lib/active_model/attribute_methods.rb:435:in `method_missing'
- activerecord (4.1.9) lib/active_record/attribute_methods.rb:213:in `method_missing'
- lib/active_admin/filter_saver/controller.rb:35:in `save_filters?'
- config/initializers/active_admin.rb:165:in `block (2 levels) in <top (required)>'
- activesupport (4.1.9) lib/active_support/callbacks.rb:438:in `block in make_lambda'
- activesupport (4.1.9) lib/active_support/callbacks.rb:143:in `block in halting_and_conditional'
- activesupport (4.1.9) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:229:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.9) lib/active_support/callbacks.rb:86:in `run_callbacks'
- actionpack (4.1.9) lib/abstract_controller/callbacks.rb:19:in `process_action'
- actionpack (4.1.9) lib/action_controller/metal/rescue.rb:29:in `process_action'
- config/initializers/instrumentation_notification.rb:28:in `block in process_action'
- activesupport (4.1.9) lib/active_support/notifications.rb:159:in `block in instrument'
- activesupport (4.1.9) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
- activesupport (4.1.9) lib/active_support/notifications.rb:159:in `instrument'
- config/initializers/instrumentation_notification.rb:27:in `process_action'
- actionpack (4.1.9) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
- activerecord (4.1.9) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
- actionpack (4.1.9) lib/abstract_controller/base.rb:136:in `process'
- actionview (4.1.9) lib/action_view/rendering.rb:30:in `process'
- actionpack (4.1.9) lib/action_controller/metal.rb:196:in `dispatch'
- actionpack (4.1.9) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
- actionpack (4.1.9) lib/action_controller/metal.rb:232:in `block in action'
- actionpack (4.1.9) lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
- actionpack (4.1.9) lib/action_dispatch/routing/route_set.rb:50:in `call'
- actionpack (4.1.9) lib/action_dispatch/journey/router.rb:73:in `block in call'
- actionpack (4.1.9) lib/action_dispatch/journey/router.rb:59:in `call'
- actionpack (4.1.9) lib/action_dispatch/routing/route_set.rb:685: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'
- rack (1.5.5) lib/rack/etag.rb:23:in `call'
- rack (1.5.5) lib/rack/conditionalget.rb:25:in `call'
- rack (1.5.5) lib/rack/head.rb:11:in `call'
- actionpack (4.1.9) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
- actionpack (4.1.9) lib/action_dispatch/middleware/flash.rb:254:in `call'
- rack (1.5.5) lib/rack/session/abstract/id.rb:225:in `context'
- rack (1.5.5) lib/rack/session/abstract/id.rb:220:in `call'
- actionpack (4.1.9) lib/action_dispatch/middleware/cookies.rb:562:in `call'
- activerecord (4.1.9) lib/active_record/query_cache.rb:36:in `call'
- activerecord (4.1.9) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
- actionpack (4.1.9) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
- activesupport (4.1.9) lib/active_support/callbacks.rb:82:in `run_callbacks'
- actionpack (4.1.9) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
- actionpack (4.1.9) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
- better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
- better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
- better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
- actionpack (4.1.9) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
- actionpack (4.1.9) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
- railties (4.1.9) lib/rails/rack/logger.rb:38:in `call_app'
- railties (4.1.9) lib/rails/rack/logger.rb:20:in `block in call'
- activesupport (4.1.9) lib/active_support/tagged_logging.rb:68:in `block in tagged'
- activesupport (4.1.9) lib/active_support/tagged_logging.rb:26:in `tagged'
- activesupport (4.1.9) lib/active_support/tagged_logging.rb:68:in `tagged'
- railties (4.1.9) lib/rails/rack/logger.rb:20:in `call'
- request_store (1.1.0) lib/request_store/middleware.rb:8:in `call'
- actionpack (4.1.9) lib/action_dispatch/middleware/request_id.rb:21:in `call'
- rack (1.5.5) lib/rack/methodoverride.rb:21:in `call'
- rack (1.5.5) lib/rack/runtime.rb:17:in `call'
- activesupport (4.1.9) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
- actionpack (4.1.9) lib/action_dispatch/middleware/static.rb:84:in `call'
- rack (1.5.5) lib/rack/sendfile.rb:112:in `call'
- railties (4.1.9) lib/rails/engine.rb:514:in `call'
- railties (4.1.9) lib/rails/application.rb:144:in `call'
- rack (1.5.5) lib/rack/builder.rb:138:in `call'
- rack (1.5.5) lib/rack/urlmap.rb:65:in `block in call'
- rack (1.5.5) lib/rack/urlmap.rb:50:in `call'
- rack-test (0.6.3) lib/rack/mock_session.rb:30:in `request'
- rack-test (0.6.3) lib/rack/test.rb:244:in `process_request'
- rack-test (0.6.3) lib/rack/test.rb:58:in `get'
- /usr/lib/ruby/2.2.0/forwardable.rb:183:in `get'
- capybara (2.5.0) lib/capybara/rack_test/browser.rb:60:in `process'
- capybara (2.5.0) lib/capybara/rack_test/browser.rb:35:in `process_and_follow_redirects'
- capybara (2.5.0) lib/capybara/rack_test/browser.rb:21:in `visit'
- capybara (2.5.0) lib/capybara/rack_test/driver.rb:42:in `visit'
- capybara (2.5.0) lib/capybara/session.rb:232:in `visit'
- capybara (2.5.0) lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
- rspec-rails (3.2.0) lib/rspec/rails/example/feature_example_group.rb:28:in `visit'
- spec/features/sign_in_feature_spec.rb:7:in `block (2 levels) in <top (required)>'
- rspec-core (3.2.0) lib/rspec/core/example.rb:177:in `block in run'
- rspec-core (3.2.0) lib/rspec/core/example.rb:385:in `block in with_around_and_singleton_context_hooks'
- rspec-core (3.2.0) lib/rspec/core/example.rb:343:in `block in with_around_example_hooks'
- rspec-core (3.2.0) lib/rspec/core/hooks.rb:474:in `block in run'
- rspec-core (3.2.0) lib/rspec/core/hooks.rb:614:in `block in run_around_example_hooks_for'
- rspec-core (3.2.0) lib/rspec/core/example.rb:247:in `call'
- rspec-rails (3.2.0) lib/rspec/rails/adapters.rb:111:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
- rspec-core (3.2.0) lib/rspec/core/example.rb:333:in `instance_exec'
- rspec-core (3.2.0) lib/rspec/core/hooks.rb:387:in `execute_with'
- rspec-core (3.2.0) lib/rspec/core/hooks.rb:616:in `block (2 levels) in run_around_example_hooks_for'
- rspec-core (3.2.0) lib/rspec/core/example.rb:247:in `call'
- rspec-core (3.2.0) lib/rspec/core/hooks.rb:617:in `run_around_example_hooks_for'
- rspec-core (3.2.0) lib/rspec/core/hooks.rb:474:in `run'
- rspec-core (3.2.0) lib/rspec/core/example.rb:343:in `with_around_example_hooks'
- rspec-core (3.2.0) lib/rspec/core/example.rb:385:in `with_around_and_singleton_context_hooks'
- rspec-core (3.2.0) lib/rspec/core/example.rb:174:in `run'
- rspec-core (3.2.0) lib/rspec/core/example_group.rb:548:in `block in run_examples'
- rspec-core (3.2.0) lib/rspec/core/example_group.rb:544:in `run_examples'
- rspec-core (3.2.0) lib/rspec/core/example_group.rb:512:in `run'
- rspec-core (3.2.0) lib/rspec/core/runner.rb:110:in `block (3 levels) in run_specs'
- rspec-core (3.2.0) lib/rspec/core/runner.rb:110:in `block (2 levels) in run_specs'
- rspec-core (3.2.0) lib/rspec/core/configuration.rb:1526:in `with_suite_hooks'
- rspec-core (3.2.0) lib/rspec/core/runner.rb:109:in `block in run_specs'
- rspec-core (3.2.0) lib/rspec/core/reporter.rb:62:in `report'
- rspec-core (3.2.0) lib/rspec/core/runner.rb:108:in `run_specs'
- rspec-core (3.2.0) lib/rspec/core/runner.rb:86:in `run'
- rspec-core (3.2.0) lib/rspec/core/runner.rb:70:in `run'
- rspec-core (3.2.0) lib/rspec/core/runner.rb:38:in `invoke'
- rspec-core (3.2.0) exe/rspec:4:in `<top (required)>'
- ruby/2.1.0/bin/rspec:23:in `<top (required)>'
- -e:1:in `<main>'
What can cause this backtrace? Is there some problem with the test environment configuration? When I switched to ENV["RAILS_ENV"] ||= 'development' the problem persists, but if I run the application in development all is OK and after auth I see the correct page.

Thanks all.
After running tests, testing database was cleared, so I have no entry for user which tried to login therefore method saved_filters could not be found. When I have added this user, I have seen page of my application.

Related

After migration to postgresql from sqlite some Rspec tests stopped passing

I created Rails application with sqlite database. After some time I decided to switch to postgresql in development environment also. I use postgresql in production (Heroku).
I have 59 Rspec tests and they all pass when using sqlite. But after migration to postgresql some of them start failing. I noticed that in some examples FactoryGirl didn't create objects, so application display error when going to for example /words/1 url that it couldn't find Word with such ID.
The only way I was able to make tests pass again was changing database_cleaner configuration.
From:
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
To:
config.before(:each) do
DatabaseCleaner.strategy = :truncation
end
Another tricky way to pass all tests was making all of them js: true.
Do you have any ideas how to fix this issue? What's the correct solution here?
Errors after running tests:
Failures:
1) User adds comment when signed in and try to add empty comment
Failure/Error: fill_in 'Treść komentarza:', with: ''
Capybara::ElementNotFound:
Unable to find field "Treść komentarza:"
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/finders.rb:44:in `block in find'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/base.rb:85:in `synchronize'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/finders.rb:33:in `find'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/actions.rb:59:in `fill_in'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/session.rb:699:in `block (2 levels) in <class:Session>'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/dsl.rb:52:in `block (2 levels) in <module:DSL>'
# ./spec/features/user_adds_comment_spec.rb:25:in `block (2 levels) in <top (required)>'
2) User adds comment when signed out
Failure/Error: expect(page).to have_content 'Zaloguj się, aby dodać komentarz'
expected to find text "Zaloguj się, aby dodać komentarz" in "ActiveRecord::RecordNotFound at /words/1 ======================================== > Couldn't find Word with 'id'=1 app/views/words/show.html.haml, line 1 -------------------------------------- ``` ruby > 1 - title \"\#{word.pl} po angielsku to \#{word.en}\" 2 .row 3 .col-md-12 4 %h1= word.en 5 .col-md-4 6 %p ``` App backtrace ------------- - app/views/words/show.html.haml:1:in `_app_views_words_show_html_haml__1962247352459501123_87235100' - spec/features/user_adds_comment_spec.rb:33:in `block (2 levels) in ' Full backtrace -------------- - activerecord (4.2.6) lib/active_record/relation/finder_methods.rb:324:in `raise_record_not_found_exception!' - activerecord (4.2.6) lib/active_record/relation/finder_methods.rb:444:in `find_one' - activerecord (4.2.6) lib/active_record/relation/finder_methods.rb:423:in `find_with_ids' - activerecord (4.2.6) lib/active_record/relation/finder_methods.rb:71:in `find' - decent_exposure (2.3.3) lib/decent_exposure/active_record_strategy.rb:60:in `singular_resource' - decent_exposure (2.3.3) lib/decent_exposure/active_record_strategy.rb:70:in `resource' - decent_exposure (2.3.3) lib/decent_exposure/strategies/assign_from_method.rb:14:in `resource' - decent_exposure (2.3.3) lib/decent_exposure/exposure.rb:14:in `call' - decent_exposure (2.3.3) lib/decent_exposure/expose.rb:53:in `block in define_exposure_methods' - actionpack (4.2.6) lib/abstract_controller/helpers.rb:67:in `word' - app/views/words/show.html.haml:1:in `_app_views_words_show_html_haml__1962247352459501123_87235100' - actionview (4.2.6) lib/action_view/template.rb:145:in `block in render' - activesupport (4.2.6) lib/active_support/notifications.rb:166:in `instrument' - actionview (4.2.6) lib/action_view/template.rb:333:in `instrument' - actionview (4.2.6) lib/action_view/template.rb:143:in `render' - actionview (4.2.6) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template' - actionview (4.2.6) lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument' - activesupport (4.2.6) lib/active_support/notifications.rb:164:in `block in instrument' - activesupport (4.2.6) lib/active_support/notifications/instrumenter.rb:20:in `instrument' - activesupport (4.2.6) lib/active_support/notifications.rb:164:in `instrument' - actionview (4.2.6) lib/action_view/renderer/abstract_renderer.rb:39:in `instrument' - actionview (4.2.6) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template' - actionview (4.2.6) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout' - actionview (4.2.6) lib/action_view/renderer/template_renderer.rb:52:in `render_template' - actionview (4.2.6) lib/action_view/renderer/template_renderer.rb:14:in `render' - actionview (4.2.6) lib/action_view/renderer/renderer.rb:46:in `render_template' - actionview (4.2.6) lib/action_view/renderer/renderer.rb:27:in `render' - actionview (4.2.6) lib/action_view/rendering.rb:100:in `_render_template' - actionpack (4.2.6) lib/action_controller/metal/streaming.rb:217:in `_render_template' - actionview (4.2.6) lib/action_view/rendering.rb:83:in `render_to_body' - actionpack (4.2.6) lib/action_controller/metal/rendering.rb:32:in `render_to_body' - actionpack (4.2.6) lib/action_controller/metal/renderers.rb:37:in `render_to_body' - actionpack (4.2.6) lib/abstract_controller/rendering.rb:25:in `render' - actionpack (4.2.6) lib/action_controller/metal/rendering.rb:16:in `render' - actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render' - activesupport (4.2.6) lib/active_support/core_ext/benchmark.rb:12:in `block in ms' - /home/hubert/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/benchmark.rb:308:in `realtime' - activesupport (4.2.6) lib/active_support/core_ext/benchmark.rb:12:in `ms' - actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:44:in `block in render' - actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime' - activerecord (4.2.6) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime' - actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:43:in `render' - remotipart (1.2.1) lib/remotipart/render_overrides.rb:14:in `render_with_remotipart' - actionpack (4.2.6) lib/action_controller/metal/implicit_render.rb:10:in `default_render' - actionpack (4.2.6) lib/action_controller/metal/implicit_render.rb:4:in `send_action' - actionpack (4.2.6) lib/abstract_controller/base.rb:198:in `process_action' - actionpack (4.2.6) lib/action_controller/metal/rendering.rb:10:in `process_action' - actionpack (4.2.6) lib/abstract_controller/callbacks.rb:20:in `block in process_action' - activesupport (4.2.6) lib/active_support/callbacks.rb:117:in `call' - activesupport (4.2.6) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile' - activesupport (4.2.6) lib/active_support/callbacks.rb:505:in `call' - activesupport (4.2.6) lib/active_support/callbacks.rb:92:in `__run_callbacks__' - activesupport (4.2.6) lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks' - activesupport (4.2.6) lib/active_support/callbacks.rb:81:in `run_callbacks' - actionpack (4.2.6) lib/abstract_controller/callbacks.rb:19:in `process_action' - actionpack (4.2.6) lib/action_controller/metal/rescue.rb:29:in `process_action' - actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action' - activesupport (4.2.6) lib/active_support/notifications.rb:164:in `block in instrument' - activesupport (4.2.6) lib/active_support/notifications/instrumenter.rb:20:in `instrument' - activesupport (4.2.6) lib/active_support/notifications.rb:164:in `instrument' - actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:30:in `process_action' - actionpack (4.2.6) lib/action_controller/metal/params_wrapper.rb:250:in `process_action' - activerecord (4.2.6) lib/active_record/railties/controller_runtime.rb:18:in `process_action' - actionpack (4.2.6) lib/abstract_controller/base.rb:137:in `process' - actionview (4.2.6) lib/action_view/rendering.rb:30:in `process' - actionpack (4.2.6) lib/action_controller/metal.rb:196:in `dispatch' - actionpack (4.2.6) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch' - actionpack (4.2.6) lib/action_controller/metal.rb:237:in `block in action' - actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:74:in `dispatch' - actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:43:in `serve' - actionpack (4.2.6) lib/action_dispatch/journey/router.rb:43:in `block in serve' - actionpack (4.2.6) lib/action_dispatch/journey/router.rb:30:in `serve' - actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:817:in `call' - rack-pjax (0.8.0) lib/rack/pjax.rb:12:in `call' - warden (1.2.6) lib/warden/manager.rb:35:in `block in call' - warden (1.2.6) lib/warden/manager.rb:34:in `call' - rack (1.6.4) lib/rack/etag.rb:24:in `call' - rack (1.6.4) lib/rack/conditionalget.rb:25:in `call' - rack (1.6.4) lib/rack/head.rb:13:in `call' - remotipart (1.2.1) lib/remotipart/middleware.rb:27:in `call' - actionpack (4.2.6) lib/action_dispatch/middleware/params_parser.rb:27:in `call' - actionpack (4.2.6) lib/action_dispatch/middleware/flash.rb:260:in `call' - rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context' - rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call' - actionpack (4.2.6) lib/action_dispatch/middleware/cookies.rb:560:in `call' - activerecord (4.2.6) lib/active_record/query_cache.rb:36:in `call' - activerecord (4.2.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call' - actionpack (4.2.6) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' - activesupport (4.2.6) lib/active_support/callbacks.rb:88:in `__run_callbacks__' - activesupport (4.2.6) lib/active_support/callbacks.rb:778:in `_run_call_callbacks' - activesupport (4.2.6) lib/active_support/callbacks.rb:81:in `run_callbacks' - actionpack (4.2.6) lib/action_dispatch/middleware/callbacks.rb:27:in `call' - actionpack (4.2.6) lib/action_dispatch/middleware/remote_ip.rb:78:in `call' - better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call' - better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call' - better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call' - actionpack (4.2.6) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' - web-console (2.3.0) lib/web_console/middleware.rb:28:in `block in call' - web-console (2.3.0) lib/web_console/middleware.rb:18:in `call' - actionpack (4.2.6) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' - railties (4.2.6) lib/rails/rack/logger.rb:38:in `call_app' - railties (4.2.6) lib/rails/rack/logger.rb:20:in `block in call' - activesupport (4.2.6) lib/active_support/tagged_logging.rb:68:in `block in tagged' - activesupport (4.2.6) lib/active_support/tagged_logging.rb:26:in `tagged' - activesupport (4.2.6) lib/active_support/tagged_logging.rb:68:in `tagged' - railties (4.2.6) lib/rails/rack/logger.rb:20:in `call' - request_store (1.3.1) lib/request_store/middleware.rb:9:in `call' - actionpack (4.2.6) lib/action_dispatch/middleware/request_id.rb:21:in `call' - rack (1.6.4) lib/rack/methodoverride.rb:22:in `call' - rack (1.6.4) lib/rack/runtime.rb:18:in `call' - activesupport (4.2.6) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call' - rack (1.6.4) lib/rack/lock.rb:17:in `call' - actionpack (4.2.6) lib/action_dispatch/middleware/static.rb:120:in `call' - rack (1.6.4) lib/rack/sendfile.rb:113:in `call' - railties (4.2.6) lib/rails/engine.rb:518:in `call' - railties (4.2.6) lib/rails/application.rb:165:in `call' - rack (1.6.4) lib/rack/urlmap.rb:66:in `block in call' - rack (1.6.4) lib/rack/urlmap.rb:50:in `call' - rack-test (0.6.3) lib/rack/mock_session.rb:30:in `request' - rack-test (0.6.3) lib/rack/test.rb:244:in `process_request' - rack-test (0.6.3) lib/rack/test.rb:58:in `get' - /home/hubert/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/forwardable.rb:184:in `get' - capybara (2.7.1) lib/capybara/rack_test/browser.rb:61:in `process' - capybara (2.7.1) lib/capybara/rack_test/browser.rb:36:in `process_and_follow_redirects' - capybara (2.7.1) lib/capybara/rack_test/browser.rb:22:in `visit' - capybara (2.7.1) lib/capybara/rack_test/driver.rb:43:in `visit' - capybara (2.7.1) lib/capybara/session.rb:233:in `visit' - capybara (2.7.1) lib/capybara/dsl.rb:52:in `block (2 levels) in ' - rspec-rails (3.5.0) lib/rspec/rails/example/feature_example_group.rb:29:in `visit' - spec/features/user_adds_comment_spec.rb:33:in `block (2 levels) in ' - rspec-core (3.5.0) lib/rspec/core/example.rb:252:in `block in run' - rspec-core (3.5.0) lib/rspec/core/example.rb:494:in `block in with_around_and_singleton_context_hooks' - rspec-core (3.5.0) lib/rspec/core/example.rb:451:in `block in with_around_example_hooks' - rspec-core (3.5.0) lib/rspec/core/hooks.rb:471:in `block in run' - rspec-core (3.5.0) lib/rspec/core/hooks.rb:611:in `block in run_around_example_hooks_for' - rspec-core (3.5.0) lib/rspec/core/example.rb:336:in `call' - rspec-rails (3.5.0) lib/rspec/rails/adapters.rb:127:in `block (2 levels) in ' - rspec-core (3.5.0) lib/rspec/core/example.rb:441:in `instance_exec' - rspec-core (3.5.0) lib/rspec/core/hooks.rb:382:in `execute_with' - rspec-core (3.5.0) lib/rspec/core/hooks.rb:613:in `block (2 levels) in run_around_example_hooks_for' - rspec-core (3.5.0) lib/rspec/core/example.rb:336:in `call' - rspec-core (3.5.0) lib/rspec/core/hooks.rb:614:in `run_around_example_hooks_for' - rspec-core (3.5.0) lib/rspec/core/hooks.rb:471:in `run' - rspec-core (3.5.0) lib/rspec/core/example.rb:451:in `with_around_example_hooks' - rspec-core (3.5.0) lib/rspec/core/example.rb:494:in `with_around_and_singleton_context_hooks' - rspec-core (3.5.0) lib/rspec/core/example.rb:249:in `run' - rspec-core (3.5.0) lib/rspec/core/example_group.rb:613:in `block in run_examples' - rspec-core (3.5.0) lib/rspec/core/example_group.rb:609:in `run_examples' - rspec-core (3.5.0) lib/rspec/core/example_group.rb:575:in `run' - rspec-core (3.5.0) lib/rspec/core/runner.rb:113:in `block (3 levels) in run_specs' - rspec-core (3.5.0) lib/rspec/core/runner.rb:113:in `block (2 levels) in run_specs' - rspec-core (3.5.0) lib/rspec/core/configuration.rb:1837:in `with_suite_hooks' - rspec-core (3.5.0) lib/rspec/core/runner.rb:112:in `block in run_specs' - rspec-core (3.5.0) lib/rspec/core/reporter.rb:77:in `report' - rspec-core (3.5.0) lib/rspec/core/runner.rb:111:in `run_specs' - rspec-core (3.5.0) lib/rspec/core/runner.rb:87:in `run' - rspec-core (3.5.0) lib/rspec/core/runner.rb:71:in `run' - rspec-core (3.5.0) lib/rspec/core/runner.rb:45:in `invoke' - rspec-core (3.5.0) exe/rspec:4:in `' - () home/hubert/.rvm/gems/ruby-2.3.0/bin/rspec:23:in `' - () home/hubert/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `'"
# ./spec/features/user_adds_comment_spec.rb:35:in `block (2 levels) in <top (required)>'
3) User create word with missing en value
Failure/Error: find(:css, ".check_boxes[value='1']").set(true)
Capybara::ElementNotFound:
Unable to find css ".check_boxes[value='1']"
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/finders.rb:44:in `block in find'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/base.rb:85:in `synchronize'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/finders.rb:33:in `find'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/session.rb:699:in `block (2 levels) in <class:Session>'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/dsl.rb:52:in `block (2 levels) in <module:DSL>'
# ./spec/features/user_creates_word_spec.rb:26:in `block (2 levels) in <top (required)>'
4) User create word with missing pl value
Failure/Error: find(:css, ".check_boxes[value='1']").set(true)
Capybara::ElementNotFound:
Unable to find css ".check_boxes[value='1']"
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/finders.rb:44:in `block in find'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/base.rb:85:in `synchronize'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/finders.rb:33:in `find'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/session.rb:699:in `block (2 levels) in <class:Session>'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/dsl.rb:52:in `block (2 levels) in <module:DSL>'
# ./spec/features/user_creates_word_spec.rb:33:in `block (2 levels) in <top (required)>'
5) User create word try add the same word twice
Failure/Error: find(:css, ".check_boxes[value='1']").set(true)
Capybara::ElementNotFound:
Unable to find css ".check_boxes[value='1']"
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/finders.rb:44:in `block in find'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/base.rb:85:in `synchronize'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/finders.rb:33:in `find'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/session.rb:699:in `block (2 levels) in <class:Session>'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/dsl.rb:52:in `block (2 levels) in <module:DSL>'
# ./spec/features/user_creates_word_spec.rb:48:in `block (2 levels) in <top (required)>'
6) User create word strip word if add unnecessary spaces
Failure/Error: find(:css, ".check_boxes[value='1']").set(true)
Capybara::ElementNotFound:
Unable to find css ".check_boxes[value='1']"
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/finders.rb:44:in `block in find'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/base.rb:85:in `synchronize'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/finders.rb:33:in `find'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/session.rb:699:in `block (2 levels) in <class:Session>'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/dsl.rb:52:in `block (2 levels) in <module:DSL>'
# ./spec/features/user_creates_word_spec.rb:64:in `block (2 levels) in <top (required)>'
7) User does not see import option when signed in and he is admin
Failure/Error: User.find(1).update(admin: true)
ActiveRecord::RecordNotFound:
Couldn't find User with 'id'=1
# ./spec/features/user_does_not_see_import_option_spec.rb:19:in `block (2 levels) in <top (required)>'
8) User can only edit his words that belongs to him
Failure/Error: find(:css, ".check_boxes[value='1']").set(true)
Capybara::ElementNotFound:
Unable to find css ".check_boxes[value='1']"
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/finders.rb:44:in `block in find'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/base.rb:85:in `synchronize'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/finders.rb:33:in `find'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/session.rb:699:in `block (2 levels) in <class:Session>'
# /home/hubert/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/dsl.rb:52:in `block (2 levels) in <module:DSL>'
# ./spec/features/user_edits_word_spec.rb:17:in `block (2 levels) in <top (required)>'
My solution for this is code below. I'm using only :truncation for feature tests. I hope it will help someone. Probably answer for why it works like that is here: https://github.com/DatabaseCleaner/database_cleaner#rspec-with-capybara-example
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, type: :feature) do
DatabaseCleaner.strategy = :truncation
end

why Rails call a method does't exist in current version(4.2.0)?

I works on a Rails project, using Rails 4.2.0, gemfile:
gem 'rails', '4.2.0'
# other gems.........
we have these two models:
class shop < ActiveRecord::Base
has_many :shop_categories
end
class ShopCategory < ActiveRecord::Base
# has a column named "shop_id"
belongs_to :shop
def self.some_max(shop)
# line number: 33
where(shop: shop).maximum(:some_value)
end
end
and we have a generator, which will call the "some_max" method on ShopCategory:
# simplified, but just like this
shop = Shop.first
# lib/generators/shop/build/build_generator.rb:36
ShopCategory.some_max shop
and the generator is invoked by code inside our Rails application:
# app/services/shop_service.rb:8
Rails::Generators.invoke 'shop:build', [..params..]
and we get this error:
NoMethodError (undefined method `convert_value_to_association_ids' for ActiveRecord::PredicateBuilder:Class):
composite_primary_keys (8.1.3) lib/composite_primary_keys/relation/predicate_builder.rb:24:in `expand'
activerecord (4.2.0) lib/active_record/relation/predicate_builder.rb:43:in `block in build_from_hash'
activerecord (4.2.0) lib/active_record/relation/predicate_builder.rb:21:in `each'
activerecord (4.2.0) lib/active_record/relation/predicate_builder.rb:21:in `build_from_hash'
activerecord (4.2.0) lib/active_record/relation/query_methods.rb:958:in `build_where'
activerecord (4.2.0) lib/active_record/relation/query_methods.rb:584:in `where!'
activerecord (4.2.0) lib/active_record/relation/query_methods.rb:574:in `where'
activerecord (4.2.0) lib/active_record/querying.rb:10:in `where'
app/models/shop_category.rb:33:in `block in <class:ShopCategory>'
activerecord (4.2.0) lib/active_record/scoping/named.rb:155:in `call'
activerecord (4.2.0) lib/active_record/scoping/named.rb:155:in `block (2 levels) in scope'
activerecord (4.2.0) lib/active_record/relation.rb:302:in `scoping'
activerecord (4.2.0) lib/active_record/scoping/named.rb:155:in `block in scope'
app/models/shop_category.rb:28:in `block in <class:ShopCategory>'
activesupport (4.2.0) lib/active_support/callbacks.rb:443:in `instance_exec'
activesupport (4.2.0) lib/active_support/callbacks.rb:443:in `block in make_lambda'
activesupport (4.2.0) lib/active_support/callbacks.rb:163:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:163:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:219:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:219:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:219:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:219:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:219:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:219:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:219:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:219:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:219:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:219:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_create_callbacks'
activerecord (4.2.0) lib/active_record/callbacks.rb:306:in `_create_record'
activerecord (4.2.0) lib/active_record/timestamp.rb:57:in `_create_record'
activerecord (4.2.0) lib/active_record/persistence.rb:501:in `create_or_update'
activerecord (4.2.0) lib/active_record/callbacks.rb:302:in `block in create_or_update'
activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:219:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:219:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:219:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:219:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:219:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:219:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_save_callbacks'
activerecord (4.2.0) lib/active_record/callbacks.rb:302:in `create_or_update'
activerecord (4.2.0) lib/active_record/persistence.rb:120:in `save'
activerecord (4.2.0) lib/active_record/validations.rb:37:in `save'
activerecord (4.2.0) lib/active_record/attribute_methods/dirty.rb:21:in `save'
activerecord (4.2.0) lib/active_record/transactions.rb:286:in `block (2 levels) in save'
activerecord (4.2.0) lib/active_record/transactions.rb:347:in `block in with_transaction_returning_status'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
activerecord (4.2.0) lib/active_record/transactions.rb:220:in `transaction'
activerecord (4.2.0) lib/active_record/transactions.rb:344:in `with_transaction_returning_status'
activerecord (4.2.0) lib/active_record/transactions.rb:286:in `block in save'
activerecord (4.2.0) lib/active_record/transactions.rb:301:in `rollback_active_record_state!'
activerecord (4.2.0) lib/active_record/transactions.rb:285:in `save'
activerecord (4.2.0) lib/active_record/associations/singular_association.rb:79:in `_create_record'
activerecord (4.2.0) lib/active_record/associations/singular_association.rb:21:in `create'
activerecord (4.2.0) lib/active_record/associations/builder/singular_association.rb:22:in `create_shop_category'
lib/generators/shop/build/build_generator.rb:36:in `create_shop_category'
lib/generators/shop/build/build_generator.rb:30:in `copy_shop_files'
thor (0.19.1) lib/thor/command.rb:27:in `run'
thor (0.19.1) lib/thor/invocation.rb:126:in `invoke_command'
thor (0.19.1) lib/thor/invocation.rb:133:in `block in invoke_all'
thor (0.19.1) lib/thor/invocation.rb:133:in `each'
thor (0.19.1) lib/thor/invocation.rb:133:in `map'
thor (0.19.1) lib/thor/invocation.rb:133:in `invoke_all'
thor (0.19.1) lib/thor/group.rb:232:in `dispatch'
thor (0.19.1) lib/thor/base.rb:440:in `start'
railties (4.2.0) lib/rails/generators.rb:157:in `invoke'
app/services/shop_service.rb:8:in `build'
app/controllers/after_registers_controller.rb:180:in `go_shop_step'
app/controllers/after_registers_controller.rb:107:in `go_retail_steps'
app/controllers/after_registers_controller.rb:46:in `update'
actionpack (4.2.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_process_action_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.0) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal.rb:236:in `block in action'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:42:in `serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
rack-raw-upload (1.1.1) lib/rack/raw_upload.rb:18:in `call'
warden (1.2.6) lib/warden/manager.rb:35:in `block in call'
warden (1.2.6) lib/warden/manager.rb:34:in `catch'
warden (1.2.6) lib/warden/manager.rb:34:in `call'
rack (1.6.4) lib/rack/etag.rb:24:in `call'
rack (1.6.4) lib/rack/conditionalget.rb:38:in `call'
rack (1.6.4) lib/rack/head.rb:13:in `call'
remotipart (1.2.1) lib/remotipart/middleware.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
activerecord (4.2.0) lib/active_record/migration.rb:378:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
web-console (2.3.0) lib/web_console/middleware.rb:20:in `block in call'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `catch'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
rack-cors (0.4.0) lib/rack/cors.rb:80:in `call'
railties (4.2.0) lib/rails/engine.rb:518:in `call'
railties (4.2.0) lib/rails/application.rb:164:in `call'
rack (1.6.4) lib/rack/content_length.rb:15:in `call'
thin (1.6.4) lib/thin/connection.rb:86:in `block in pre_process'
thin (1.6.4) lib/thin/connection.rb:84:in `catch'
thin (1.6.4) lib/thin/connection.rb:84:in `pre_process'
thin (1.6.4) lib/thin/connection.rb:53:in `process'
thin (1.6.4) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.2.0.1) lib/eventmachine.rb:194:in `run_machine'
eventmachine (1.2.0.1) lib/eventmachine.rb:194:in `run'
thin (1.6.4) lib/thin/backends/base.rb:73:in `start'
thin (1.6.4) lib/thin/server.rb:162:in `start'
rack (1.6.4) lib/rack/handler/thin.rb:19:in `run'
rack (1.6.4) lib/rack/server.rb:286:in `start'
railties (4.2.0) lib/rails/commands/server.rb:80:in `start'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:80:in `block in server'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:75:in `tap'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:75:in `server'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:39:in `run_command!'
railties (4.2.0) lib/rails/commands.rb:17:in `<top (required)>'
bin/rails:8:in `require'
bin/rails:8:in `<top (required)>'
spring (1.7.1) lib/spring/client/rails.rb:28:in `load'
spring (1.7.1) lib/spring/client/rails.rb:28:in `call'
spring (1.7.1) lib/spring/client/command.rb:7:in `call'
spring (1.7.1) lib/spring/client.rb:30:in `run'
spring (1.7.1) bin/spring:49:in `<top (required)>'
spring (1.7.1) lib/spring/binstub.rb:11:in `load'
spring (1.7.1) lib/spring/binstub.rb:11:in `<top (required)>'
/home/robin/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/home/robin/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
bin/spring:13:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Rendered /home/robin/.rvm/gems/ruby-2.2.3/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/_source.erb (12.4ms)
Rendered /home/robin/.rvm/gems/ruby-2.2.3/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (4.1ms)
Rendered /home/robin/.rvm/gems/ruby-2.2.3/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.3ms)
Rendered /home/robin/.rvm/gems/ruby-2.2.3/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (32.8ms)
I understood this errore happened when Rails try convert this line:
where(shop: shop).maximum(:some_value)
to something like that:
# when I change the line above to this, the error disappeared
where(shop_id: shop.id).maximum(:some_value)
also, I checked the Rails document, and found that ActiveRecord::PredicateBuilder has a class method called "convert_value_to_association_ids" in Rails version 4.2.1, but not in 4.2.0. So why Rails call a method does't exist in current version(4.2.0)? Does this have something to do with the environment of the generator invoking? Thanks in advance.
===========================================
Update:
In my rails project, i run "bundle show activerecord", it give me a path to my activerecord gem, and follow this path, I open the file in "lib/active_record/relation/predicate_builder.rb", and I can't find the class method "convert_value_to_association_ids" in this file.
The error is actually coming from composite_primary_keys, v8.1.3, not rails/activerecord:
value = convert_value_to_association_ids(value, primary_key)
It uses this method, even though it depends on activerecord 4.2.0, in which the method does not yet exist. It's a bug in that version of the composite_primary_keys gem.

Unable to get serializer to serialize has_many association

So I am using the latest active_model_serializer and I am trying to use them to send an array on Medium.
I use this to make a query for the Medium: Medium.includes([{comments: :user}, :user]).where(user_id: user_ids)
So the Medium belong to a user, medium has many comments and every comment has a user (owner).
Now here are the corresponding serializers:
Medium:
class MediumSerializer < ActiveModel::Serializer
attributes :id,
:text,
:image_video_file_name,
:image_video_croppable_url,
:image_video_thumb_url,
:image_video_big_url
belongs_to :user
has_many :comments
end
Comment:
class CommentSerializer < ActiveModel::Serializer
attributes :id,
:text,
:user_id,
:medium_id
belongs_to :user
end
User:
class UserSerializer < ActiveModel::Serializer
include Avatar
attributes :id,
:name,
:email,
:role,
:avatar
def avatar
Medium.find(self.current_avatar)[0]
end
#has_one :avatar, serializer: AvatarSerializer
has_many :media, :comments
end
And also I have these functions in my Medium:
def image_video_croppable_url
image_video.url(:croppable)
end
def image_video_thumb_url
image_video.url(:thumb)
end
def image_video_big_url
image_video.url(:big)
end
I use Paperclip gem and I needed these functions to get access to sizes of different medium images. Maybe there is a better way for it also.
So now when I do the query, I use this line to pass the info to browser and let the serializer make it JSON nicely:
respond_with media, each_serializer: MediumSerializer
But it gives me this error:
NoMethodError - undefined method `image_video_file_name' for #<Comment:0x007f5a082a4310>:
activemodel (4.2.0) lib/active_model/attribute_methods.rb:433:in `method_missing'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer.rb:37:in `block (2 levels) in attributes'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer.rb:200:in `block in attributes'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer.rb:198:in `each'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer.rb:198:in `each_with_object'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer.rb:198:in `attributes'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter/json.rb:22:in `block (3 levels) in serializable_hash'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter.rb:53:in `cache_check'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter/json.rb:21:in `block (2 levels) in serializable_hash'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/array_serializer.rb:5:in `each'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/array_serializer.rb:5:in `each'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter/json.rb:20:in `map'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter/json.rb:20:in `block in serializable_hash'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer.rb:224:in `call'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer.rb:224:in `block in each_association'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer.rb:208:in `each'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer.rb:208:in `each_association'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter/json.rb:17:in `serializable_hash'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter/json.rb:9:in `block in serializable_hash'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/array_serializer.rb:5:in `each'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/array_serializer.rb:5:in `each'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter/json.rb:9:in `map'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter/json.rb:9:in `serializable_hash'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter.rb:23:in `as_json'
activesupport (4.2.0) lib/active_support/json/encoding.rb:34:in `encode'
activesupport (4.2.0) lib/active_support/json/encoding.rb:21:in `encode'
activesupport (4.2.0) lib/active_support/core_ext/object/json.rb:37:in `to_json_with_active_support_encoder'
actionpack (4.2.0) lib/action_controller/metal/renderers.rb:116:in `block in <module:Renderers>'
active_model_serializers (0.10.0.rc1) lib/action_controller/serialization.rb:49:in `block (2 levels) in <module:Serialization>'
actionpack (4.2.0) lib/action_controller/metal/renderers.rb:45:in `block in _render_to_body_with_renderer'
/home/kaspar/.rbenv/versions/2.2.0/lib/ruby/2.2.0/set.rb:283:in `each_key'
/home/kaspar/.rbenv/versions/2.2.0/lib/ruby/2.2.0/set.rb:283:in `each'
actionpack (4.2.0) lib/action_controller/metal/renderers.rb:41:in `_render_to_body_with_renderer'
actionpack (4.2.0) lib/action_controller/metal/renderers.rb:37:in `render_to_body'
actionpack (4.2.0) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.2.0) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
activesupport (4.2.0) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/home/kaspar/.rbenv/versions/2.2.0/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
activesupport (4.2.0) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:40:in `render'
responders (2.1.0) lib/action_controller/responder.rb:258:in `display'
responders (2.1.0) lib/action_controller/responder.rb:212:in `api_behavior'
responders (2.1.0) lib/action_controller/responder.rb:191:in `rescue in to_format'
responders (2.1.0) lib/action_controller/responder.rb:185:in `to_format'
responders (2.1.0) lib/action_controller/responder.rb:163:in `respond'
responders (2.1.0) lib/action_controller/responder.rb:156:in `call'
responders (2.1.0) lib/action_controller/respond_with.rb:203:in `respond_with'
app/controllers/users_controller.rb:73:in `feed'
actionpack (4.2.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_process_action_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.0) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal.rb:236:in `block in action'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:42:in `serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.0) 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.1) lib/rack/etag.rb:24:in `call'
rack (1.6.1) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.1) lib/rack/head.rb:13:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.1) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.1) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
activerecord (4.2.0) lib/active_record/migration.rb:378:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.1) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.1) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.1) lib/rack/lock.rb:17:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.1) lib/rack/sendfile.rb:113:in `call'
railties (4.2.0) lib/rails/engine.rb:518:in `call'
railties (4.2.0) lib/rails/application.rb:164:in `call'
passenger (5.0.7) lib/phusion_passenger/rack/thread_handler_extension.rb:89:in `process_request'
passenger (5.0.7) lib/phusion_passenger/request_handler/thread_handler.rb:149:in `accept_and_process_next_request'
passenger (5.0.7) lib/phusion_passenger/request_handler/thread_handler.rb:110:in `main_loop'
passenger (5.0.7) lib/phusion_passenger/request_handler.rb:414:in `block (3 levels) in start_threads'
passenger (5.0.7) lib/phusion_passenger/utils.rb:111:in `block in create_thread_and_abort_on_exception'
This error only occurs when I attempt to throw an array of Medium to the Serializer. With only one Medium I get no errors and the result is this:
As you can see it has all the attributes I wanted it to have in the serializer and it managed to fetch the info into all the attributes with no problems.
Why does this problem occur only when I do the same thing with an array or same objects?

undefined method `first' on update in rails

I import a csv file into my DB and i have a error when I update it.
My error :
undefined method `first' for nil:NilClass
on line "if agent.update(line)"
My model :
def self.import_agent(file)
fallback = {:counter => 0}
CSV.foreach(file.path, :col_sep => "\t", :headers => true, :quote_char => "\x00", :encoding => 'windows-1251:utf-8') do |row|
line = Hash.new
row.to_hash.each_pair do |k,v|
row ={k.downcase.gsub("agent_", "") => v}
line = line.deep_merge(row)
end
agent = Agent.find_or_initialize_by(code:line["code"])
if agent.update(line)
fallback[:counter] += 1
end
end
return fallback
end
My Controller :
def import_agent
#file = params[:file]
fallback = Import.import_agent(#file)
redirect_to root_path, notice: 'File successfully uploaded, '+fallback[:counter].to_s+' line are added/updated !'
end
Error Log :
Started POST "/import_agent" for 127.0.0.1 at 2015-03-30 11:06:18 +0200
Processing by ImportsController#import_agent as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"pF1GsZ+Z+9tHmiw6k47Y7T7Sjn1ka1bHZqMqwWbBO2QIHBIz2VX9F7kPGP0CyYT6xu3nJnANJdGjDCtE0eISjw==", "file"=>#<ActionDispatch::Http::UploadedFile:0x007ff3d9fccba8 #tempfile=#<Tempfile:/var/folders/xw/pqcy6hjd59x29wf0wqcbhp1h0000gn/T/RackMultipart20150330-7818-f99zac.csv>, #original_filename="EXPORT_AGENT.csv", #content_type="text/csv", #headers="Content-Disposition: form-data; name=\"file\"; filename=\"EXPORT_AGENT.csv\"\r\nContent-Type: text/csv\r\n">, "commit"=>"Import Agent CSV"}
Agent Load (0.3ms) SELECT "agents".* FROM "agents" WHERE "agents"."code" = ? LIMIT 1 [["code", "AG001"]]
(0.1ms) begin transaction
(0.1ms) rollback transaction
Completed 500 Internal Server Error in 62ms
NoMethodError - undefined method `first' for nil:NilClass:
activerecord (4.2.0) lib/active_record/attribute_assignment.rb:114:in `find_parameter_position'
activerecord (4.2.0) lib/active_record/attribute_assignment.rb:103:in `block in extract_callstack_for_multiparameter_attributes'
activerecord (4.2.0) lib/active_record/attribute_assignment.rb:98:in `extract_callstack_for_multiparameter_attributes'
activerecord (4.2.0) lib/active_record/attribute_assignment.rb:76:in `assign_multiparameter_attributes'
activerecord (4.2.0) lib/active_record/attribute_assignment.rb:46:in `assign_attributes'
activerecord (4.2.0) lib/active_record/persistence.rb:249:in `block in update'
activerecord (4.2.0) lib/active_record/transactions.rb:347:in `block in with_transaction_returning_status'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
activerecord (4.2.0) lib/active_record/transactions.rb:220:in `transaction'
activerecord (4.2.0) lib/active_record/transactions.rb:344:in `with_transaction_returning_status'
activerecord (4.2.0) lib/active_record/persistence.rb:248:in `update'
app/models/import.rb:67:in `block in import_agent'
/Users/gregoryfrerot/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/csv.rb:1739:in `each'
/Users/gregoryfrerot/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/csv.rb:1122:in `block in foreach'
/Users/gregoryfrerot/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/csv.rb:1273:in `open'
/Users/gregoryfrerot/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/csv.rb:1121:in `foreach'
app/models/import.rb:60:in `import_agent'
app/controllers/imports_controller.rb:16:in `import_agent'
actionpack (4.2.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_process_action_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.0) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal.rb:236:in `block in action'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:42:in `serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
bullet (4.14.4) 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'
rack (1.6.0) lib/rack/etag.rb:24:in `call'
rack (1.6.0) lib/rack/conditionalget.rb:38:in `call'
rack (1.6.0) lib/rack/head.rb:13:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.0) 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) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
activerecord (4.2.0) lib/active_record/migration.rb:378:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
web-console (2.0.0) lib/action_dispatch/debug_exceptions.rb:18:in `middleware_call'
web-console (2.0.0) lib/action_dispatch/debug_exceptions.rb:13:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
actionpack (4.2.0) 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) 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) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.0) lib/rack/sendfile.rb:113:in `call'
railties (4.2.0) lib/rails/engine.rb:518:in `call'
railties (4.2.0) lib/rails/application.rb:164:in `call'
rack (1.6.0) lib/rack/content_length.rb:15:in `call'
thin (1.6.3) lib/thin/connection.rb:86:in `block in pre_process'
thin (1.6.3) lib/thin/connection.rb:84:in `pre_process'
thin (1.6.3) lib/thin/connection.rb:53:in `process'
thin (1.6.3) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.0.5) lib/eventmachine.rb:187:in `run'
thin (1.6.3) lib/thin/backends/base.rb:73:in `start'
thin (1.6.3) lib/thin/server.rb:162:in `start'
rack (1.6.0) lib/rack/handler/thin.rb:19:in `run'
rack (1.6.0) lib/rack/server.rb:286:in `start'
railties (4.2.0) lib/rails/commands/server.rb:80:in `start'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:80:in `block in server'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:75:in `server'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:39:in `run_command!'
railties (4.2.0) lib/rails/commands.rb:17:in `<top (required)>'
bin/rails:4:in `<main>'
Thanks for your help and sorry for my english.
Use find_or_create_by instead of find_or_initialize_by, since the latter does not insert new record into database.

Rails: undefined method 'ingredients' for nil:NilClass

I am new to Rails so pardon if this question is relatively simple - I went through all the other similar errors on SO and no solutions were of use.
I am trying to print a list of ingredients from this api call and getting the error Rails: undefined method 'ingredients' for nil:NilClass. Any help is appreciated!
My code snippets are:
about page:
<% content_for :title do %>About<% end %>
<h3>About the Website</h3>
<p>
This web application was created with
<%= link_to('Rails Composer', 'http://railsapps.github.io/rails-composer/') %>
from the <%= link_to('RailsApps project', 'http://railsapps.github.io/') %>.
Ingredients are <%= #recommendations.ingredients %>
</p>
model:
class Recommendations
require 'httparty'
attr_accessor :matches, :ingredients
def fetch_recipe
encoded_url = URI.encode("http://api.yummly.com/v1/api/recipes?_app_id=ca19779e&_app_key=125204344682094834d68637a8222adf&q=chicken&allowedCourse[]=course^course-Lunch&maxResult=100&start=1")
parsed_url = URI.parse(encoded_url)
HTTParty.get(parsed_url)
end
def initialize
recipe_hash = fetch_recipe
assign_values(recipe_hash)
end
def assign_values(recipe_hash)
recipe_response = recipe_hash.parsed_response['matches'][0]
self.ingredients = recipe_response['ingredients']
end
end
controller:
class RecommendationsController < ApplicationController
def home
#recommendations = Recommendations.new
end
end
logs:
Started GET "/pages/about" for 127.0.0.1 at 2014-07-28 17:43:40 -0700
Processing by HighVoltage::PagesController#show as HTML
Parameters: {"id"=>"about"}
Rendered pages/about.html.erb within layouts/application (1.0ms)
Completed 500 Internal Server Error in 4ms
NoMethodError - undefined method `ingredients' for nil:NilClass:
app/views/pages/about.html.erb:7:in `_app_views_pages_about_html_erb___310183375408592724_70240131703120'
actionview (4.1.2) lib/action_view/template.rb:145:in `block in render'
activesupport (4.1.2) lib/active_support/notifications.rb:161:in `instrument'
actionview (4.1.2) lib/action_view/template.rb:339:in `instrument'
actionview (4.1.2) lib/action_view/template.rb:143:in `render'
actionview (4.1.2) lib/action_view/renderer/template_renderer.rb:55:in `block (2 levels) in render_template'
actionview (4.1.2) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (4.1.2) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.2) lib/active_support/notifications.rb:159:in `instrument'
actionview (4.1.2) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionview (4.1.2) lib/action_view/renderer/template_renderer.rb:54:in `block in render_template'
actionview (4.1.2) lib/action_view/renderer/template_renderer.rb:62:in `render_with_layout'
actionview (4.1.2) lib/action_view/renderer/template_renderer.rb:53:in `render_template'
actionview (4.1.2) lib/action_view/renderer/template_renderer.rb:17:in `render'
actionview (4.1.2) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (4.1.2) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (4.1.2) lib/action_view/rendering.rb:99:in `_render_template'
actionpack (4.1.2) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (4.1.2) lib/action_view/rendering.rb:82:in `render_to_body'
actionpack (4.1.2) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
actionpack (4.1.2) lib/action_controller/metal/renderers.rb:32:in `render_to_body'
actionpack (4.1.2) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.1.2) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.1.2) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
activesupport (4.1.2) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
activesupport (4.1.2) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.1.2) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
actionpack (4.1.2) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (4.1.2) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.1.2) lib/action_controller/metal/instrumentation.rb:40:in `render'
high_voltage (2.2.0) app/controllers/concerns/high_voltage/static_page.rb:28:in `show'
actionpack (4.1.2) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.2) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.2) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.2) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.2) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.2) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.2) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.2) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.2) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.2) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.2) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.2) lib/active_support/callbacks.rb:149:in `call'
activesupport (4.1.2) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.2) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.2) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.2) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.2) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.2) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.2) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.2) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.2) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.2) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.2) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.2) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.2) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.2) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.2) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.2) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.2) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.1.2) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.2) lib/action_controller/metal.rb:232:in `block in action'
actionpack (4.1.2) lib/action_dispatch/routing/route_set.rb:82:in `call'
actionpack (4.1.2) lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
actionpack (4.1.2) lib/action_dispatch/routing/route_set.rb:50:in `call'
actionpack (4.1.2) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.2) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.1.2) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.2) lib/action_dispatch/routing/route_set.rb:678:in `call'
bullet (4.12.0) lib/bullet/rack.rb:10:in `call'
meta_request (0.3.3) lib/meta_request/middlewares/app_request_handler.rb:13:in `call'
rack-contrib (1.1.0) lib/rack/contrib/response_headers.rb:17:in `call'
meta_request (0.3.3) lib/meta_request/middlewares/headers.rb:16:in `call'
meta_request (0.3.3) lib/meta_request/middlewares/meta_request_handler.rb:13: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.1.2) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.2) lib/action_dispatch/middleware/flash.rb:254:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.1.2) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.1.2) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.1.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
activerecord (4.1.2) lib/active_record/migration.rb:380:in `call'
actionpack (4.1.2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.2) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.2) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.2) lib/action_dispatch/middleware/remote_ip.rb:76: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 (4.1.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.2) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.2) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.2) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.2) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.2) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.0.3) lib/quiet_assets.rb:23:in `call_with_quiet_assets'
actionpack (4.1.2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.2) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.2) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.2) lib/rails/engine.rb:514:in `call'
railties (4.1.2) lib/rails/application.rb:144:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
thin (1.6.2) lib/thin/connection.rb:86:in `block in pre_process'
thin (1.6.2) lib/thin/connection.rb:84:in `catch'
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_machine'
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'
rack (1.5.2) lib/rack/handler/thin.rb:16:in `run'
rack (1.5.2) lib/rack/server.rb:264:in `start'
railties (4.1.2) lib/rails/commands/server.rb:69:in `start'
railties (4.1.2) lib/rails/commands/commands_tasks.rb:81:in `block in server'
railties (4.1.2) lib/rails/commands/commands_tasks.rb:76:in `tap'
railties (4.1.2) lib/rails/commands/commands_tasks.rb:76:in `server'
railties (4.1.2) lib/rails/commands/commands_tasks.rb:40:in `run_command!'
railties (4.1.2) lib/rails/commands.rb:17:in `<top (required)>'
bin/rails:8:in `require'
bin/rails:8:in `<top (required)>'
spring (1.1.3) lib/spring/client/rails.rb:27:in `load'
spring (1.1.3) lib/spring/client/rails.rb:27:in `call'
spring (1.1.3) lib/spring/client/command.rb:7:in `call'
spring (1.1.3) lib/spring/client.rb:26:in `run'
spring (1.1.3) bin/spring:48:in `<top (required)>'
spring (1.1.3) lib/spring/binstub.rb:11:in `load'
spring (1.1.3) lib/spring/binstub.rb:11:in `<top (required)>'
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
bin/spring:16:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
class RecommendationsController < ApplicationController
def home
#recommendations = Recommendations.new
end
def about
#recommendations = Recommendations.new
end
end
add the recommendations instantiation to your about action too.
Better yet, refactor it into a method:
class RecommendationsController < ApplicationController
before_filter :new_recommendation, :only =>[:home, :about]
private
def new_recommentation
#recommendations = Recommendations.new
end
end
Ingredients of nil can, most logically, be also nil. Solve your problem by defining
def nil.ingredients
nil
end

Resources