FactoryGirl::create throwing NoMethodError: undefined method `stringify_keys' - ruby-on-rails

I have the follwing in my factories.rb:
factory :ffsupervisor, class: Supervisor do
first_name "ffsupervisor"
email "ffsupervisor#abc.com"
password "123456"
type "Supervisor"
association :agency, name: "FFAgency", full_fee: "2.0", partial_fee: "1.0", agency_type: "Fulfilment"
end
I'm able to build and save an instance of Supervisor in my DB with FactoryGirl::create(:ffsupervisor) in the Rails Console. When I try to do the same thing in my feature specs, I end up getting:
NoMethodError: undefined method `stringify_keys'.
I've looked into a lot of questions in SO regarding this issue. Haven't been able to figure out what I'm missing out though. Any heads up on this would be great. TIA!
EDIT:
This is the stack trace I'm getting:
1) Workflow order_item lifecycle.
Failure/Error: #supervisor= FactoryGirl::create(:ffsupervisor) # Creates both agency & supervisor.
NoMethodError:
undefined method `stringify_keys' for #<Supervisor:0x0000000baa9410>
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activemodel-4.0.0/lib/active_model/attribute_methods.rb:436:in `method_missing'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/attribute_methods.rb:131:in `method_missing'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/attribute_assignment.rb:17:in `assign_attributes'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/core.rb:192:in `initialize'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/devise-3.3.0/lib/devise/models/confirmable.rb:47:in `initialize'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/inheritance.rb:27:in `new'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/inheritance.rb:27:in `new'
# ./app/mailers/synup_mailer.rb:13:in `confirmation_instructions'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionpack-4.0.0/lib/abstract_controller/base.rb:189:in `process_action'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionpack-4.0.0/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:373:in `_run__1572042514373682743__process_action__callbacks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionpack-4.0.0/lib/abstract_controller/callbacks.rb:17:in `process_action'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionpack-4.0.0/lib/abstract_controller/base.rb:136:in `process'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionpack-4.0.0/lib/abstract_controller/rendering.rb:44:in `process'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionmailer-4.0.0/lib/action_mailer/base.rb:503:in `process'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionmailer-4.0.0/lib/action_mailer/base.rb:497:in `initialize'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/resque_mailer-2.2.6/lib/resque_mailer.rb:121:in `new'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/resque_mailer-2.2.6/lib/resque_mailer.rb:121:in `actual_message'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/resque_mailer-2.2.6/lib/resque_mailer.rb:97:in `initialize'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/resque_mailer-2.2.6/lib/resque_mailer.rb:40:in `new'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/resque_mailer-2.2.6/lib/resque_mailer.rb:40:in `method_missing'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/devise-3.3.0/lib/devise/models/authenticatable.rb:173:in `send_devise_notification'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/devise-3.3.0/lib/devise/models/confirmable.rb:102:in `send_confirmation_instructions'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/devise-3.3.0/lib/devise/models/confirmable.rb:158:in `send_on_create_confirmation_instructions'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:397:in `_run__462299154380556768__create__callbacks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/callbacks.rb:303:in `create_record'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/timestamp.rb:57:in `create_record'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/persistence.rb:466:in `create_or_update'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/callbacks.rb:299:in `block in create_or_update'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:393:in `_run__462299154380556768__save__callbacks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/callbacks.rb:299:in `create_or_update'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/persistence.rb:128:in `save!'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/validations.rb:57:in `save!'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/attribute_methods/dirty.rb:41:in `save!'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/transactions.rb:275:in `block in save!'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/transactions.rb:326:in `block in with_transaction_returning_status'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/ar_after_transaction-0.4.0/lib/ar_after_transaction.rb:19:in `block in transaction_with_after'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/transactions.rb:209:in `transaction'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/ar_after_transaction-0.4.0/lib/ar_after_transaction.rb:17:in `transaction_with_after'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/transactions.rb:323:in `with_transaction_returning_status'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/transactions.rb:275:in `save!'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/configuration.rb:14:in `block in initialize'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/evaluation.rb:15:in `[]'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/evaluation.rb:15:in `create'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:12:in `block in result'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:9:in `tap'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:9:in `result'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/factory.rb:42:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/factory_runner.rb:23:in `block in run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/notifications.rb:161:in `instrument'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/factory_runner.rb:22:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/strategy_syntax_method_registrar.rb:19:in `block in define_singular_strategy_method'
# ./spec/features/workflow_spec.rb:39:in `block (2 levels) in <top (required)>'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:114:in `instance_eval'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:114:in `block in run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:179:in `call'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:179:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_exec'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_eval_with_args'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:247:in `instance_eval_with_args'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/hooks.rb:87:in `block (2 levels) in run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/hooks.rb:89:in `call'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/hooks.rb:89:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/hooks.rb:418:in `run_hook'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:329:in `run_around_each_hooks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:256:in `with_around_each_hooks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:111:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:390:in `block in run_examples'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:386:in `map'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:386:in `run_examples'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:371:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:28:in `map'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:28:in `block in run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/reporter.rb:34:in `report'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:25:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'

Related

Rails rspec and cucumber Secret token is empty

When running rspec or cucumber tests I get this error:
Secret token is empty
I have my secret_key_base set in my env
Stacktrace:
RuntimeError:
Secret token is empty
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/ahoy_email-1.1.0/lib/ahoy_email/processor.rb:103:in `block in track_links'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/nokogiri-1.10.5/lib/nokogiri/xml/node_set.rb:238:in `block in each'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/nokogiri-1.10.5/lib/nokogiri/xml/node_set.rb:237:in `upto'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/nokogiri-1.10.5/lib/nokogiri/xml/node_set.rb:237:in `each'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/ahoy_email-1.1.0/lib/ahoy_email/processor.rb:88:in `track_links'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/ahoy_email-1.1.0/lib/ahoy_email/processor.rb:17:in `perform'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/ahoy_email-1.1.0/lib/ahoy_email/mailer.rb:39:in `block in save_ahoy_options'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/safely_block-0.3.0/lib/safely/core.rb:50:in `safely'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/ahoy_email-1.1.0/lib/ahoy_email/mailer.rb:27:in `save_ahoy_options'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:413:in `block in make_lambda'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:246:in `block in halting'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:511:in `block in invoke_after'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:511:in `each'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:511:in `invoke_after'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:132:in `run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionpack-5.1.7/lib/abstract_controller/callbacks.rb:19:in `process_action'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionpack-5.1.7/lib/abstract_controller/base.rb:124:in `process'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/rescuable.rb:23:in `block in process'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/rescuable.rb:15:in `handle_exceptions'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/rescuable.rb:22:in `process'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionview-5.1.7/lib/action_view/rendering.rb:30:in `process'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/base.rb:609:in `block in process'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/notifications.rb:166:in `block in instrument'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/notifications.rb:166:in `instrument'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/base.rb:608:in `process'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/message_delivery.rb:105:in `block in processed_mailer'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/message_delivery.rb:104:in `tap'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/message_delivery.rb:104:in `processed_mailer'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/message_delivery.rb:95:in `deliver_now'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/delivery_job.rb:14:in `perform'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/execution.rb:37:in `block in perform_now'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:108:in `block in run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/i18n-0.9.5/lib/i18n.rb:268:in `with_locale'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/translation.rb:7:in `block (2 levels) in <module:Translation>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:117:in `instance_exec'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/logging.rb:24:in `block (4 levels) in <module:Logging>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/notifications.rb:166:in `block in instrument'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/notifications.rb:166:in `instrument'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/logging.rb:23:in `block (3 levels) in <module:Logging>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/logging.rb:44:in `block in tag_logger'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/tagged_logging.rb:69:in `block in tagged'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/tagged_logging.rb:26:in `tagged'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/tagged_logging.rb:69:in `tagged'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/logging.rb:44:in `tag_logger'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/logging.rb:20:in `block (2 levels) in <module:Logging>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:117:in `instance_exec'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:135:in `run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/execution.rb:33:in `perform_now'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/execution.rb:22:in `block in execute'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:108:in `block in run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/railtie.rb:26:in `block (4 levels) in <class:Railtie>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/execution_wrapper.rb:85:in `wrap'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/reloader.rb:68:in `block in wrap'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/execution_wrapper.rb:85:in `wrap'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/reloader.rb:67:in `wrap'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/railtie.rb:25:in `block (3 levels) in <class:Railtie>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:117:in `instance_exec'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:135:in `run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/execution.rb:20:in `execute'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/queue_adapters/delayed_job_adapter.rb:36:in `perform'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/backend/base.rb:81:in `block in invoke_job'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/lifecycle.rb:61:in `block in initialize'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/lifecycle.rb:66:in `execute'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/lifecycle.rb:40:in `run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/backend/base.rb:78:in `invoke_job'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/backend/base.rb:19:in `block (2 levels) in enqueue_job'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/lifecycle.rb:61:in `block in initialize'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/lifecycle.rb:66:in `execute'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/lifecycle.rb:40:in `run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/backend/base.rb:17:in `block in enqueue_job'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/backend/base.rb:16:in `tap'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/backend/base.rb:16:in `enqueue_job'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/backend/base.rb:12:in `enqueue'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/queue_adapters/delayed_job_adapter.rb:17:in `enqueue'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/enqueuing.rb:51:in `block in enqueue'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:108:in `block in run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/logging.rb:15:in `block (3 levels) in <module:Logging>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/logging.rb:44:in `block in tag_logger'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/tagged_logging.rb:69:in `block in tagged'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/tagged_logging.rb:26:in `tagged'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/tagged_logging.rb:69:in `tagged'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/logging.rb:44:in `tag_logger'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/logging.rb:14:in `block (2 levels) in <module:Logging>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:117:in `instance_exec'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:135:in `run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/enqueuing.rb:47:in `enqueue'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/configured_job.rb:13:in `perform_later'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/message_delivery.rb:121:in `enqueue_delivery'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/message_delivery.rb:76:in `deliver_later'
# ./app/models/group_user.rb:182:in `send_email_joined_group'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:413:in `block in make_lambda'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:235:in `block in halting_and_conditional'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:511:in `block in invoke_after'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:511:in `each'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:511:in `invoke_after'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:132:in `run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:827:in `_run_create_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/callbacks.rb:344:in `_create_record'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/timestamp.rb:102:in `_create_record'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/persistence.rb:554:in `create_or_update'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/callbacks.rb:340:in `block in create_or_update'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:131:in `run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:827:in `_run_save_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/callbacks.rb:340:in `create_or_update'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/persistence.rb:162:in `save!'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/validations.rb:50:in `save!'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/attribute_methods/dirty.rb:43:in `save!'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/transactions.rb:313:in `block in save!'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/transactions.rb:384:in `block in with_transaction_returning_status'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `block in transaction'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/connection_adapters/abstract/transaction.rb:194:in `block in within_new_transaction'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/connection_adapters/abstract/transaction.rb:191:in `within_new_transaction'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `transaction'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/transactions.rb:210:in `transaction'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/transactions.rb:381:in `with_transaction_returning_status'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/transactions.rb:313:in `save!'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/suppressor.rb:46:in `save!'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/factory_bot-5.1.1/lib/factory_bot/evaluation.rb:18:in `create'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/factory_bot-5.1.1/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/factory_bot-5.1.1/lib/factory_bot/strategy/create.rb:9:in `tap'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/factory_bot-5.1.1/lib/factory_bot/strategy/create.rb:9:in `result'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/factory_bot-5.1.1/lib/factory_bot/factory.rb:43:in `run'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/factory_bot-5.1.1/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/notifications.rb:168:in `instrument'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/factory_bot-5.1.1/lib/factory_bot/factory_runner.rb:28:in `run'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/factory_bot-5.1.1/lib/factory_bot/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
# ./spec/features/groups/groups_show_spec.rb:17:in `block (3 levels) in <top (required)>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/rspec-prof-0.0.7/lib/rspec-prof.rb:76:in `block (2 levels) in <top (required)>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:286:in `load'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:286:in `block in load'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:258:in `load_dependency'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:286:in `load'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/spring-commands-rspec-1.0.4/lib/spring/commands/rspec.rb:18:in `call'
# -e:1:in `<main>'
I went to:
.rvm/gems/ruby-2.4.6/gems/ahoy_email-1.1.0/lib/ahoy_email/processor.rb:103
There I found:
raise "Secret token is empty" unless AhoyEmail.secret_token
which meant that the secret_token in the ahoy gem isn't set.I went to:
.rvm/gems/ruby-2.4.6/gems/ahoy_email-1.1.0/lib/ahoy_email/engine.rb
I found that I have commented a lot of the stuff there for debugging purposes.
gem uninstall ahoy_email -v 1.1.0
gem install ahoy_email -v 1.1.0
And it worked.
Moral of the story: 'Do not work in your gems folder.'

Rails 5.1, Errno::EMFILE: Too many open files - getcwd

I've started seeing this error in the past couple of days when running my entire /spec directory. I doubt it is revealing anything about the state of my tests - it occurs randomly. My hunch is it might be a configuration issue in rails_helper.rb.
Errno::EMFILE:
Too many open files - getcwd
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/carrierwave-0.11.2/lib/carrierwave/sanitized_file.rb:115:in `expand_path'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/carrierwave-0.11.2/lib/carrierwave/sanitized_file.rb:115:in `path'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/carrierwave-0.11.2/lib/carrierwave/sanitized_file.rb:146:in `exists?'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/carrierwave-0.11.2/lib/carrierwave/sanitized_file.rb:95:in `size'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/carrierwave-0.11.2/lib/carrierwave/sanitized_file.rb:137:in `empty?'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/carrierwave-0.11.2/lib/carrierwave/uploader/cache.rb:131:in `cache!'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/carrierwave-0.11.2/lib/carrierwave/mount.rb:329:in `cache'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/carrierwave-0.11.2/lib/carrierwave/mount.rb:163:in `attachment='
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/carrierwave-base64-2.5.3/lib/carrierwave/base64/adapter.rb:26:in `block in mount_base64_uploader'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:16:in `public_send'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:16:in `block (2 levels) in object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `each'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `block in object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `tap'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluation.rb:12:in `object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:9:in `result'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory.rb:42:in `run'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:29:in `block in run'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.2/lib/active_support/notifications.rb:168:in `instrument'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:28:in `run'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:5:in `association'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:33:in `association'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute/association.rb:19:in `block in to_proc'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:77:in `instance_exec'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:77:in `block in define_attribute'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:56:in `get'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:16:in `block (2 levels) in object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `each'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `block in object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `tap'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluation.rb:12:in `object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:9:in `result'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory.rb:42:in `run'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:29:in `block in run'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.2/lib/active_support/notifications.rb:168:in `instrument'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:28:in `run'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:5:in `association'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:33:in `association'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute/association.rb:19:in `block in to_proc'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:77:in `instance_exec'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:77:in `block in define_attribute'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:56:in `get'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:16:in `block (2 levels) in object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `each'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `block in object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `tap'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluation.rb:12:in `object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:9:in `result'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory.rb:42:in `run'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:29:in `block in run'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.2/lib/active_support/notifications.rb:168:in `instrument'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:28:in `run'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:5:in `association'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:33:in `association'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute/association.rb:19:in `block in to_proc'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:77:in `instance_exec'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:77:in `block in define_attribute'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:56:in `get'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:16:in `block (2 levels) in object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `each'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `block in object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `tap'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluation.rb:12:in `object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:9:in `result'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory.rb:42:in `run'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:29:in `block in run'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.2/lib/active_support/notifications.rb:168:in `instrument'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:28:in `run'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:5:in `association'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:33:in `association'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute/association.rb:19:in `block in to_proc'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:77:in `instance_exec'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:77:in `block in define_attribute'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:56:in `get'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:16:in `block (2 levels) in object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `each'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `block in object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `tap'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluation.rb:12:in `object'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:9:in `result'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory.rb:42:in `run'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:29:in `block in run'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.2/lib/active_support/notifications.rb:168:in `instrument'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:28:in `run'
# /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
The stack trace is always the same. I can't see anywhere explicitly in my code where a file is being opened.
I'd recently implemented DatabaseCleaner with the following options:
config.use_transactional_fixtures = false
config.before(:each) do
Sidekiq::Worker.clear_all
end
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
RedisCache.new.flushdb
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
They had this problem connected with Carrierwave 0.5.8.
The post is from 14/Mar/2012 so it is for sure outdated
I can confirm that carrierwave up until 0.5.7 works correctly. Only 0.5.8 causes this problem. I'm going to open an issue in carrierwave later tonight.
But you have Carrierwave 0.11.2

Rails Mailer TypeError on #deliver

I'm trying to debug this mailer error in 4.1.1 and can't figure out how to get more information on what to look into:
TypeError (no implicit conversion of nil into String):
app/controllers/api/v1/contact_form_controller.rb:5:in `create'
Here's the controller, line 5 in the error is the second line here:
def create
#mail = ContactFormMailer.contact_email(contact_params).deliver
# ContactFormSender.perform_async(contact_params)
render nothing: true, status: 200
end
My mailer looks like this:
class ContactFormMailer < ActionMailer::Base
default from: ENV["CONTACT_EMAIL"]
def contact_email(args)
#from = args[:from]
#body = args[:body]
#title = args[:title]
mail(to: ENV["CONTACT_EMAIL"], subject: 'Contact form')
end
end
The error only throws when I call deliver, which leads me to believe that it's a mailer.config issue, but everything I've looked into for gmail seems correct:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { :host => ENV["DOMAIN"] }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings =
{
address: ENV["SMTP_SERVER"],
port: 587,
domain: ENV["MAILER_DOMAIN"],
authentication: "plain",
enable_starttls_auto: true,
user_name: ENV["SMTP_USER"],
password: ENV["SMTP_PWD"]
}
I doubled checked all of my ENV variables and tried putting begin rescue end around my controller action to get more information on the error, but it just says it's a type error. Is there anyway I can get more information from a logger or something? The error makes me think it's a config setting or something that isn't being passed through, but I have no idea where to keep looking.
Edit: Here's the rest of the error:
Rendered /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (1.0ms)
Rendered /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.1ms)
Rendered /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.5ms)
Rendered /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (28.8ms)
Edit 2: here's the real backtrace:
# /Users/evan/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/smtp.rb:541:in `initialize'
# /Users/evan/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/smtp.rb:541:in `open'
# /Users/evan/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/smtp.rb:541:in `tcp_socket'
# /Users/evan/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/smtp.rb:551:in `block in do_start'
# /Users/evan/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/timeout.rb:91:in `block in timeout'
# /Users/evan/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/timeout.rb:101:in `call'
# /Users/evan/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/timeout.rb:101:in `timeout'
# /Users/evan/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/smtp.rb:550:in `do_start'
# /Users/evan/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/smtp.rb:520:in `start'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/mail-2.5.4/lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/mail-2.5.4/lib/mail/message.rb:248:in `deliver!'
# ./app/controllers/api/v1/contact_form_controller.rb:5:in `create'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/abstract_controller/base.rb:189:in `process_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_controller/metal/rendering.rb:10:in `process_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:113:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:113:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:229:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:229:in `block in halting'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:86:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:86:in `run_callbacks'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/abstract_controller/callbacks.rb:19:in `process_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_controller/metal/rescue.rb:29:in `process_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `block in instrument'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `instrument'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.1/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/abstract_controller/base.rb:136:in `process'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionview-4.1.1/lib/action_view/rendering.rb:30:in `process'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_controller/test_case.rb:595:in `process'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_controller/test_case.rb:64:in `process'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_controller/test_case.rb:501:in `post'
# ./spec/controllers/api/v1/contact_form_controller_spec.rb:7:in `block (3 levels) in <top (required)>'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:151:in `instance_exec'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:151:in `block in run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:221:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:221:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-rails-3.1.0/lib/rspec/rails/example/controller_example_group.rb:179:in `block (2 levels) in <module:ControllerExampleGroup>'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:321:in `instance_exec'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:321:in `instance_exec'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/hooks.rb:380:in `execute_with'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/hooks.rb:446:in `block (2 levels) in run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:221:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:221:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-rails-3.1.0/lib/rspec/rails/adapters.rb:72:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:321:in `instance_exec'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:321:in `instance_exec'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/hooks.rb:380:in `execute_with'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/hooks.rb:446:in `block (2 levels) in run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:221:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:221:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/hooks.rb:447:in `run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/hooks.rb:500:in `run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:330:in `with_around_example_hooks'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:148:in `run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example_group.rb:500:in `block in run_examples'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example_group.rb:496:in `map'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example_group.rb:496:in `run_examples'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example_group.rb:463:in `run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example_group.rb:464:in `block in run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example_group.rb:464:in `map'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example_group.rb:464:in `run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/runner.rb:111:in `block (2 levels) in run_specs'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/runner.rb:111:in `map'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/runner.rb:111:in `block in run_specs'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/reporter.rb:53:in `report'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/runner.rb:107:in `run_specs'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/runner.rb:85:in `run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/runner.rb:69:in `run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/runner.rb:37:in `invoke'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/exe/rspec:4:in `<top (required)>'
# /Users/evan/.rvm/gems/ruby-2.1.2/bin/rspec:23:in `load'
# /Users/evan/.rvm/gems/ruby-2.1.2/bin/rspec:23:in `<main>'
# /Users/evan/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
# /Users/evan/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
Your SMTP_SERVER env variable is nil.
I can consistently reproduce this error with:
2.1.2 :004 > TCPSocket.open nil, 40
TypeError: no implicit conversion of nil into String
from (irb):4:in `initialize'
from (irb):4:in `open'
from (irb):4
from /Users/mauricio/.rvm/rubies/ruby-2.1.2/bin/irb:11:in `<main>'
You can see the actual line where it breaks here.
You should force your code to validate there's a value for all the env variables you need right at the config file instead of assuming there are values for them.

Why does before_action :authorize fail with 'wrong number of arguments'?

I have set up Pundit together with Devise for authorization on my application. In one of my controllers, I have before_action :authorize.
I then have the following test:
describe SomeController do
before(:each) do
login_user(FactoryGirl.create(:user, :user_type => :admin))
end
describe "GET index" do
it "it retrieves the index" do
something = FactoryGirl.create(:Something)
get :index
assigns(:something).should eq([something])
end
end
end
I receive the error:
wrong number of arguments (0 for 1)
The login helper is fairly straight forward:
module ControllerMacros
def login_user(user)
if user.nil?
user = FactoryGirl.create(:user)
end
#request.env["devise.mapping"] = Devise.mappings[:user]
sign_in user
end
end
Update:
Stacktrace:
Failure/Error: get :index
ArgumentError:
wrong number of arguments (0 for 1..2)
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/pundit-0.2.3/lib/pundit.rb:62:in `authorize'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:424:in `block in make_lambda'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:160:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:160:in `block in halting'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:149:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:229:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:229:in `block in halting'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:149:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:86:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:86:in `run_callbacks'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.1.1/lib/abstract_controller/callbacks.rb:19:in `process_action'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.1.1/lib/action_controller/metal/rescue.rb:29:in `process_action'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.1.1/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `block in instrument'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `instrument'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.1.1/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.1.1/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.1.1/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.1.1/lib/abstract_controller/base.rb:136:in `process'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionview-4.1.1/lib/action_view/rendering.rb:30:in `process'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.1.1/lib/action_controller/test_case.rb:595:in `process'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.1.1/lib/action_controller/test_case.rb:64:in `process'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/devise-3.2.4/lib/devise/test_helpers.rb:19:in `block in process'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/devise-3.2.4/lib/devise/test_helpers.rb:72:in `catch'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/devise-3.2.4/lib/devise/test_helpers.rb:72:in `_catch_warden'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/devise-3.2.4/lib/devise/test_helpers.rb:19:in `process'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.1.1/lib/action_controller/test_case.rb:495:in `get'
# ./spec/controllers/SomeController_spec.rb:31:in `block (4 levels) in <top (required)>'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:114:in `instance_eval'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:114:in `block in run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_exec'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_eval_with_args'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:247:in `instance_eval_with_args'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/hooks.rb:106:in `block (2 levels) in run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:179:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:179:in `run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_exec'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_eval_with_args'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:247:in `instance_eval_with_args'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/hooks.rb:106:in `block (2 levels) in run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/hooks.rb:108:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/hooks.rb:108:in `run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/hooks.rb:446:in `run_hook'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:340:in `run_around_each_hooks'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:256:in `with_around_each_hooks'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:111:in `run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:390:in `block in run_examples'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:386:in `map'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:386:in `run_examples'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:371:in `run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:372:in `block in run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:372:in `map'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:372:in `run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:372:in `block in run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:372:in `map'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:372:in `run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:28:in `map'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:28:in `block in run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/reporter.rb:58:in `report'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:25:in `run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:80:in `run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:17:in `block in autorun'
Pundit's authorize method is not intended to be called as a before_action. before_action calls a method with no arguments, and authorize takes a model object and an optional permission name. That's why you're getting the error you are.
You're not showing enough of the relevant code for me to see what you should do next, but I suggest getting Pundit to work in your controller action before pulling it out into a callback.
There is an example of the correct use of authorize here: https://github.com/elabs/pundit
You can define a private helper method in your controller(or in the application_controller if you will use it in all the controllers) which calls authorize current_user, and then call the private method before_action. Like this:
private
def perform_authorization
authorize current_user
end
and then call it as a before_action :
before_action :perform_authorization

Postgresql prepared statement in Rails : PG::Error: ERROR: bind message supplies 1 parameters, but prepared statement "a4" requires 0

I have introduced a new field to a model file in my 4.0.0 Ruby on Rails application and added a validation to make sure it is unique using the following line:
validates_uniqueness_of :source_id
Immediately after that my RSpec/Capybara test suite started breaking with the following error message:
Failure/Error: let(:product) { FactoryGirl.create(:product) }
ActiveRecord::StatementInvalid:
PG::Error: ERROR: bind message supplies 1 parameters, but prepared statement "a4" requires 0
SELECT 1 AS one FROM "products" WHERE "products"."source_id" = 'Product GUID6' LIMIT 1
I understand this has to do with Postgresql prepared statements, but am not sure as to what needs to be done exactly to resolve this issue.
As an additional piece of information, I have updated the DB table with index for field "source_id" with unique: true option.
Your input is greatly appreciated.
I am using FactoryGirl gem to handle the creation of my model object such as:
let(:product) { FactoryGirl.create(:product) }
subject { product_dimension }
describe "method" do
it { should respond_to(:product) }
end
and here is the snippet from the actual Factories.rb file:
factory :product do
sequence(:source_id) { |n| "Product GUID#{n}" }
sequence(:title) { |n| "Prodcut #{n}" }
content "Lorem ipsum"
channel_id 1
end
Here is the exception stack trace:
1) ProductDimension method dimension
Failure/Error: let(:product) { FactoryGirl.create(:product) }
ActiveRecord::StatementInvalid:
PG::Error: ERROR: bind message supplies 1 parameters, but prepared statement "a4" requires 0
: SELECT 1 AS one FROM "products" WHERE "products"."source_id" = 'Product GUID6' LIMIT 1
# ./spec/models/product_dimension_spec.rb:4:in `block (2 levels) in <top (required)>'
# ./spec/models/product_dimension_spec.rb:7:in `block (2 levels) in <top (required)>'
# ./spec/models/product_dimension_spec.rb:9:in `block (2 levels) in <top (required)>'
# ./spec/models/product_dimension_spec.rb:28:in `block (3 levels) in <top (required)>'
Here is a more detailed stack trace:
1) ProductDimension methods dimension
Failure/Error: let(:product) { FactoryGirl.create(:product) }
ActiveRecord::StatementInvalid:
PG::Error: ERROR: bind message supplies 1 parameters, but prepared statement "a4" requires 0
: SELECT 1 AS one FROM "products" WHERE "products"."source_id" = 'GUID 6' LIMIT 1
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:780:in `get_last_result'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:780:in `exec_cache'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:139:in `block in exec_query'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:425:in `block in log'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:420:in `log'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:137:in `exec_query'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:885:in `select'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:24:in `select_all'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:30:in `select_one'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:36:in `select_value'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/relation/finder_methods.rb:174:in `exists?'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/validations/uniqueness.rb:28:in `validate_each'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activemodel-4.0.0/lib/active_model/validator.rb:153:in `block in validate'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activemodel-4.0.0/lib/active_model/validator.rb:150:in `each'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activemodel-4.0.0/lib/active_model/validator.rb:150:in `validate'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:283:in `_callback_before_17'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:467:in `_run__2082443422329982594__validate__callbacks'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activemodel-4.0.0/lib/active_model/validations.rb:373:in `run_validations!'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activemodel-4.0.0/lib/active_model/validations/callbacks.rb:106:in `block in run_validations!'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:373:in `_run__2082443422329982594__validation__callbacks'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activemodel-4.0.0/lib/active_model/validations/callbacks.rb:106:in `run_validations!'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activemodel-4.0.0/lib/active_model/validations.rb:314:in `valid?'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/validations.rb:70:in `valid?'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/validations.rb:77:in `perform_validations'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/validations.rb:57:in `save!'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/attribute_methods/dirty.rb:41:in `save!'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/transactions.rb:275:in `block in save!'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/transactions.rb:326:in `block in with_transaction_returning_status'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/transactions.rb:209:in `transaction'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/transactions.rb:323:in `with_transaction_returning_status'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/transactions.rb:275:in `save!'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/configuration.rb:14:in `block in initialize'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/evaluation.rb:15:in `[]'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/evaluation.rb:15:in `create'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:12:in `block in result'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:9:in `tap'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:9:in `result'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/factory.rb:42:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/factory_runner.rb:23:in `block in run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/notifications.rb:161:in `instrument'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/factory_runner.rb:22:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/factory_girl-4.2.0/lib/factory_girl/strategy_syntax_method_registrar.rb:19:in `block in define_singular_strategy_method'
# ./spec/models/event_dimension_spec.rb:5:in `block (2 levels) in <top (required)>'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `block (2 levels) in let'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `fetch'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `block in let'
# ./spec/models/event_dimension_spec.rb:8:in `block (2 levels) in <top (required)>'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `block (2 levels) in let'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `fetch'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `block in let'
# ./spec/models/event_dimension_spec.rb:10:in `block (2 levels) in <top (required)>'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `block (2 levels) in let'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `fetch'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `block in let'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:433:in `block (2 levels) in its'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `block (2 levels) in let'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `fetch'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:199:in `block in let'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:440:in `should'
# ./spec/models/event_dimension_spec.rb:32:in `block (3 levels) in <top (required)>'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example.rb:114:in `instance_eval'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example.rb:114:in `block in run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example.rb:179:in `call'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example.rb:179:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_exec'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_eval_with_args'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example.rb:247:in `instance_eval_with_args'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/hooks.rb:87:in `block (2 levels) in run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/hooks.rb:89:in `call'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/hooks.rb:89:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/hooks.rb:427:in `run_hook'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:339:in `run_around_each_hooks'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example.rb:256:in `with_around_each_hooks'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example.rb:111:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:400:in `block in run_examples'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:396:in `map'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:396:in `run_examples'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:381:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:382:in `block in run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:382:in `map'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:382:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:382:in `block in run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:382:in `map'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:382:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/command_line.rb:28:in `map'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/command_line.rb:28:in `block in run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/reporter.rb:58:in `report'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/command_line.rb:25:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/runner.rb:80:in `run'
# /Users/kirillberlin/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.4/lib/rspec/core/runner.rb:17:in `block in autorun'
This is a bug in ActiveRecord. It will be fixed in Rails 4.0.3.
I have figured it out. Thanks to #muistooshort for pointing me in the right direction with the last comment. There was an issue with the relationship between my models. It prompted me to revise the need for my ProductDimension model at which point I completely discarded it in favour of another approach.
I came across this error while Upgrading Rails from 5.1.3 to 5.2 and I was able to fix it by updating cancancan gem to the latest version i.e 3.0.2.

Resources