How to use nested exposure when referencing the same model twice? - rails-activerecord

I have a grape entity for a Contact model, which references User model twice:
class Contact < ApplicationRecord
belongs_to :user, foreign_key: :user_id
belongs_to :contact, class_name: 'User', foreign_key: :contact_id
def entity
Entity.new(self)
end
class Entity < Grape::Entity
expose :contact do
expose :id
expose :user, as: :inviter, merge: true, using: User::Entity
expose :contact, as: :invitee, merge: true, using: User::Entity
expose :status
end
end
end
When I get an endpoint which presents contact, I have the following error
ArgumentError:
wrong number of arguments (given 3, expected 0)
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure/output_builder.rb:53:in `block in merge_strategy'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure/output_builder.rb:19:in `merge!'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure/output_builder.rb:19:in `add'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:62:in `block (2 levels) in serializable_value'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/base.rb:108:in `block in with_attr_path'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/options.rb:102:in `with_attr_path'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/base.rb:107:in `with_attr_path'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:60:in `block in serializable_value'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:59:in `each'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:59:in `each_with_object'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:59:in `serializable_value'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:61:in `block (2 levels) in serializable_value'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/base.rb:108:in `block in with_attr_path'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/options.rb:102:in `with_attr_path'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/base.rb:107:in `with_attr_path'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:60:in `block in serializable_value'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:59:in `each'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:59:in `each_with_object'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:59:in `serializable_value'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/entity.rb:473:in `serializable_hash'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/formatter/json.rb:6:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/formatter.rb:44:in `block in build_formatted_response'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/formatter.rb:44:in `collect'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/formatter.rb:44:in `build_formatted_response'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/formatter.rb:28:in `after'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/base.rb:34:in `call!'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/base.rb:24:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/base.rb:31:in `call!'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/base.rb:24:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/base.rb:31:in `call!'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/base.rb:24:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/error.rb:34:in `block in call!'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/error.rb:33:in `catch'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/error.rb:33:in `call!'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/base.rb:24:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/rack-2.0.1/lib/rack/head.rb:12:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/endpoint.rb:224:in `call!'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/endpoint.rb:218:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/router/route.rb:72:in `exec'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/router.rb:119:in `process_route'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/router.rb:74:in `block in identity'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/router.rb:93:in `transaction'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/router.rb:72:in `identity'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/router.rb:57:in `block in call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/router.rb:135:in `with_optimization'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/router.rb:56:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/api.rb:119:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/api.rb:45:in `call!'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/api.rb:40:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/rack-2.0.1/lib/rack/etag.rb:25:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/rack-2.0.1/lib/rack/conditional_get.rb:25:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/rack-2.0.1/lib/rack/head.rb:12:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/railties-5.0.1/lib/rails/rack/logger.rb:36:in `call_app'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/railties-5.0.1/lib/rails/rack/logger.rb:24:in `block in call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/railties-5.0.1/lib/rails/rack/logger.rb:24:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/rack-2.0.1/lib/rack/runtime.rb:22:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/rack-2.0.1/lib/rack/sendfile.rb:111:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/railties-5.0.1/lib/rails/engine.rb:522:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/rack-test-0.6.3/lib/rack/mock_session.rb:30:in `request'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/rack-test-0.6.3/lib/rack/test.rb:244:in `process_request'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/rack-test-0.6.3/lib/rack/test.rb:124:in `request'
# ./spec/requests/contacts_spec.rb:39:in `block (4 levels) in <top (required)>'
How to make it include User entities for both inviter and invitee in the Contact entity?

Related

Validation failed: Logo can't be blank when logo uploaded using rspec

I am creating automated tests for my rails app using rspec and factoryBot. In my case I am creating a company with a requirement of having a logo. Creating a company in the test is not a problem but if I try and modify the company outside of the test file I am getting an error message of
ActiveRecord::RecordInvalid:
Validation failed: Logo can't be blank
I have tried alternative upload methods but with no luck. Below is the factory for the company and the process I am using to create a company. This is not the exact code in my implementation as I am unable to share that but I have replicated it as much as I could.
If I manually test the code it works fine. It is only when running the code with rspec the error occurs.
factories.rb
FactoryBot.define do
factory :company do
name { 'Name' }
b_day { Date.today }
age { 1 }
logo { Rack::Test::UploadedFile.new(File.open(File.join(Rails.root, '/spec/support/logo.png')), 'image/png') }
end
end
companies_rake_spec.rb
describe "Company b_day today" do
it "Add 1 to company age" do
company1 = create(:company)
Rake::Task['companies:update_age'].invoke
company1_refresh = Company.where(id: company1.id).first
expect(company1_refresh.age).to eq(company1.age + 1)
end
end
company.rake
namespace :companies do
desc "TODO"
task update_age: :environment do
Company.find_each do | company |
if (company.b_day.day == Date.today.day) && (company.b_day.month == Date.today.month)
company.age += 1
puts company.inspect
company.save!
end
end
end
end
end
console
#<Company id: 34, name: "Name", b_day: 2018-11-13, age: 2, logo: "1cbeef36f13a8a88db0c37fa30da6ffd.png">
ActiveRecord::RecordInvalid:
Validation failed: Logo can't be blank
stacktrace
Failures:
1) companies:update_age age + 1
Failure/Error: company.save!
ActiveRecord::RecordInvalid:
Validation failed: Logo can't be blank
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/validations.rb:78:in `raise_validation_error'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/validations.rb:50:in `save!'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/attribute_methods/dirty.rb:30:in `save!'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/transactions.rb:324:in `block in save!'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/transactions.rb:395:in `block in with_transaction_returning_status'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/transactions.rb:211:in `transaction'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/transactions.rb:392:in `with_transaction_returning_status'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/transactions.rb:324:in `save!'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/suppressor.rb:45:in `save!'
# ./lib/tasks/companies.rake:54:in `block (3 levels) in <top (required)>'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/relation/batches.rb:59:in `block (2 levels) in find_each'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/relation/batches.rb:59:in `each'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/relation/batches.rb:59:in `block in find_each'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/relation/batches.rb:121:in `block in find_in_batches'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/relation/batches.rb:214:in `block in in_batches'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/relation/batches.rb:198:in `loop'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/relation/batches.rb:198:in `in_batches'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/relation/batches.rb:120:in `find_in_batches'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/relation/batches.rb:58:in `find_each'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/querying.rb:9:in `find_each'
# ./lib/tasks/companies.rake:8:in `block (2 levels) in <top (required)>'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rake-12.3.1/lib/rake/task.rb:271:in `block in execute'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rake-12.3.1/lib/rake/task.rb:271:in `each'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rake-12.3.1/lib/rake/task.rb:271:in `execute'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rake-12.3.1/lib/rake/task.rb:213:in `block in invoke_with_call_chain'
# /Users/mac/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rake-12.3.1/lib/rake/task.rb:193:in `invoke_with_call_chain'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rake-12.3.1/lib/rake/task.rb:182:in `invoke'
# ./spec/lib/tasks/companies_rake_spec.rb:122:in `block (3 levels) in <top (required)>'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:254:in `instance_exec'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:254:in `block in run'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:500:in `block in with_around_and_singleton_context_hooks'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:457:in `block in with_around_example_hooks'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/hooks.rb:464:in `block in run'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/hooks.rb:604:in `block in run_around_example_hooks_for'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:342:in `call'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-rails-3.8.0/lib/rspec/rails/adapters.rb:127:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:447:in `instance_exec'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:447:in `instance_exec'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/hooks.rb:373:in `execute_with'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/hooks.rb:606:in `block (2 levels) in run_around_example_hooks_for'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:342:in `call'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/hooks.rb:607:in `run_around_example_hooks_for'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/hooks.rb:464:in `run'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:457:in `with_around_example_hooks'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:500:in `with_around_and_singleton_context_hooks'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:251:in `run'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example_group.rb:629:in `block in run_examples'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example_group.rb:625:in `map'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example_group.rb:625:in `run_examples'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example_group.rb:591:in `run'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example_group.rb:592:in `block in run'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example_group.rb:592:in `map'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example_group.rb:592:in `run'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:116:in `block (3 levels) in run_specs'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:116:in `map'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:116:in `block (2 levels) in run_specs'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/configuration.rb:1989:in `with_suite_hooks'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:111:in `block in run_specs'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/reporter.rb:74:in `report'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:110:in `run_specs'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:87:in `run'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:71:in `run'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:45:in `invoke'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/exe/rspec:4:in `<top (required)>'
# /Users/mac/.rvm/gems/ruby-2.5.1/bin/rspec:23:in `load'
# /Users/mac/.rvm/gems/ruby-2.5.1/bin/rspec:23:in `<main>'
# /Users/mac/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:15:in `eval'
# /Users/mac/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:15:in `<main>'
How to properly do model testing with ActiveStorage in rails?
Using the info from there and adapting to your specifics, try the following factory:
FactoryBot.define do
factory :company do
name { 'Name' }
b_day { Date.today }
age { 1 }
after(:build) do |company|
company.logo.attach(io: File.open(Rails.root.join('spec', 'support', 'logo.jpeg')), filename: 'logo.jpeg', content_type: 'image/jpeg')
end
end
end
EDIT:
You may also need to add this to your config/environments/test.rb file:
config.active_storage.service = :test

Delayed Job Delayed::PerformableMethod undefined method "delayed_task" for #<Class:0x0000000b4dcd20>

I am using delayed jobs and I think I have a problem with serialization. We are using ruby 2.2.2.
In my model I have a callback that fires on save and creates a delayed job for my model. like this:
after_create :update_queue
def update_queue
self.class.delay(run_at: 1.minutes.from_now, delayed_reference_id: self.id, delayed_reference_type: "Payment", queue: "qbo_payments").delayed_task(self.id)
end
def self.delayed_task
# Do some stuff
end
However I am getting the error:
undefined method `delayed_task' for #<Class:0x0000000f93f9b8>
~/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/dynamic_matchers.rb:26:in `method_missing'
~/shared/bundle/ruby/2.2.0/gems/attr_encrypted-3.0.3/lib/attr_encrypted.rb:295:in `method_missing'
~/shared/bundle/ruby/2.2.0/gems/attr_encrypted-3.0.3/lib/attr_encrypted/adapters/active_record.rb:129:in `method_missing_with_attr_encrypted'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/performable_method.rb:26:in `perform'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/backend/base.rb:84:in `block in invoke_job'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:61:in `call'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:61:in `block in initialize'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:66:in `call'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:66:in `execute'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:40:in `run_callbacks'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/backend/base.rb:81:in `invoke_job'
~/shared/bundle/ruby/2.2.0/gems/newrelic_rpm-3.16.0.318/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb:127:in `block in invoke_job'
~/shared/bundle/ruby/2.2.0/gems/newrelic_rpm-3.16.0.318/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:363:in `perform_action_with_newrelic_trace'
~/shared/bundle/ruby/2.2.0/gems/newrelic_rpm-3.16.0.318/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb:126:in `invoke_job'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:230:in `block (2 levels) in run'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/timeout.rb:89:in `block in timeout'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/timeout.rb:99:in `call'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/timeout.rb:99:in `timeout'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:230:in `block in run'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:229:in `run'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:306:in `block in reserve_and_run_one_job'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:61:in `call'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:61:in `block in initialize'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:66:in `call'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:66:in `execute'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:40:in `run_callbacks'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:306:in `reserve_and_run_one_job'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:213:in `block in work_off'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:212:in `times'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:212:in `work_off'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:175:in `block (4 levels) in start'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:174:in `block (3 levels) in start'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:61:in `call'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:61:in `block in initialize'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:66:in `call'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:66:in `execute'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:40:in `run_callbacks'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:173:in `block (2 levels) in start'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:172:in `loop'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:172:in `block in start'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/plugins/clear_locks.rb:7:in `call'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/plugins/clear_locks.rb:7:in `block (2 levels) in <class:ClearLocks>'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:79:in `call'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:79:in `block (2 levels) in add'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:61:in `call'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:61:in `block in initialize'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:79:in `call'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:79:in `block in add'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:66:in `call'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:66:in `execute'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/lifecycle.rb:40:in `run_callbacks'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/worker.rb:171:in `start'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/command.rb:132:in `run'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/command.rb:120:in `block in run_process'
~/shared/bundle/ruby/2.2.0/gems/daemons-1.2.3/lib/daemons/application.rb:265:in `call'
~/shared/bundle/ruby/2.2.0/gems/daemons-1.2.3/lib/daemons/application.rb:265:in `block in start_proc'
~/shared/bundle/ruby/2.2.0/gems/daemons-1.2.3/lib/daemons/daemonize.rb:84:in `call'
~/shared/bundle/ruby/2.2.0/gems/daemons-1.2.3/lib/daemons/daemonize.rb:84:in `call_as_daemon'
~/shared/bundle/ruby/2.2.0/gems/daemons-1.2.3/lib/daemons/application.rb:269:in `start_proc'
~/shared/bundle/ruby/2.2.0/gems/daemons-1.2.3/lib/daemons/application.rb:295:in `start'
~/shared/bundle/ruby/2.2.0/gems/daemons-1.2.3/lib/daemons/controller.rb:69:in `run'
~/shared/bundle/ruby/2.2.0/gems/daemons-1.2.3/lib/daemons.rb:193:in `block in run_proc'
~/shared/bundle/ruby/2.2.0/gems/daemons-1.2.3/lib/daemons/cmdline.rb:88:in `call'
~/shared/bundle/ruby/2.2.0/gems/daemons-1.2.3/lib/daemons/cmdline.rb:88:in `catch_exceptions'
~/shared/bundle/ruby/2.2.0/gems/daemons-1.2.3/lib/daemons.rb:192:in `run_proc'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/command.rb:118:in `run_process'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/command.rb:99:in `block in daemonize'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/command.rb:97:in `times'
~/shared/bundle/ruby/2.2.0/gems/delayed_job-4.1.2/lib/delayed/command.rb:97:in `daemonize'
script/delayed_job:5:in `<main>'"
What I have tried
After a bit of google research I found 2 fixes. The first and more widely accepted fix is to add:
require 'yaml'
YAML::ENGINE.yamler = 'syck'
#https://github.com/collectiveidea/delayed_job/issues/199
However, syck is no longer supported for ruby 2.2.2
The second solution, which only seemed to exacerbate the problem, was to add "bundle exec" to my delayed_job startup script like this:
run "cd #{current_path}; bundle exec script/delayed_job start #{rails_env}"
This will work !
after_create :update_queue
def update_queue
self.delay(run_at: 1.minutes.from_now, delayed_reference_id: self.id, delayed_reference_type: "Payment", queue: "qbo_payments").delayed_task()
end
def delayed_task
self.class.delayed_task(self.id)
end
def self.delayed_task
# Do some stuff
end

raise_error and raise_exception are not working for me in Rspec

describe "The Original Method list_instances_of_with_resources_change" do
it "Should execute successfully and return Array of Google::Apis::DnsV1::Change object" do
expect{subject_class::list_instances_of_with_resources_change("Dummy ID",custom_params)}.to raise_error
end
end
The error which I am getting.
2) Testing Change Resource : The Original Method list_instances_of_with_resources_change Should execute successfully and return Array of Google::Apis::DnsV1::Change object
Failure/Error: response = client.send("list_changes", project, managed_zone, max_results:max_results, page_token:page_token, sort_by:sort_by, sort_order:sort_order)
Google::Apis::ClientError:
invalid: Invalid value for project: graphite-development1
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/http_command.rb:211:in `check_status'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/api_command.rb:102:in `check_status'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/http_command.rb:179:in `process_response'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/http_command.rb:286:in `execute_once'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/http_command.rb:107:in `block (2 levels) in execute'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:54:in `block in retriable'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `times'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `retriable'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/http_command.rb:104:in `block in execute'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:54:in `block in retriable'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `times'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `retriable'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/http_command.rb:96:in `execute'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/base_service.rb:345:in `execute_or_queue_command'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/generated/google/apis/dns_v1/service.rb:191:in `list_changes'
# ./lib/puppet_x/puppetlabs/google_cloud_dns/provider.rb:165:in `list_instances_of_change'
# ./spec/unit/neg_google_cloud_dns_change_spec.rb:24:in `block (2 levels) in <top (required)>'

mongoid :trying to embed a document which is embedded in another document

I'm using sinatra and i want to embed a document using the realtion Embedded 1-1
this is my main collection that embeds just one environment
class TestSuite
include Mongoid::Document
field :testSuiteName
field :introduction
field :itemsToTest
field :dateCreation
attr_accessible :testSuiteName,:introduction,:itemsToTest,:dateCreation
embeds_one :environment
embeds_many :steps
end
every TestSuite embeds many steps
class Step
include Mongoid::Document
field :stepRole
field :stepOrderNum
embedded_in :testSuite
embedded_in :environment
has_one :function
end
to run a testSuite i had to set the test environment that's embeds many steps
class Environment
include Mongoid::Document
embedded_in :testSuite
embeds_many :steps
end
get '/createTestSuite' do
name=params[:testName]
intro=params[:introduction]
items=['data','shemas']
test1=TestSuite.create()
test1.testSuiteName="firstOne"
test1. introduction="my first Test Suite"
test1.itemsToTest=["data","shemas"]
test1. dateCreation="23/01/214 18:18"
test1.environment.create()
test1.environment.steps.create(stepRole: "inserer donneés",stepOrderNum: "2")
the problem :
NoMethodError - undefined method `create' for nil:NilClass:
C:/Users/mohamedamine.sakhri/Documents/Aptana Studio 3 Workspace/zProject/main.rb:99:in `block in <main>'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `block in compile!'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `[]'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (3 levels) in route!'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:985:in `route_eval'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (2 levels) in route!'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1006:in `block in process_route'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `catch'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `process_route'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:964:in `block in route!'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `each'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `route!'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1076:in `block in dispatch!'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1073:in `dispatch!'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `block in call!'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `call!'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:886:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/logger.rb:15:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/commonlogger.rb:33:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:217:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:210:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/show_exceptions.rb:21:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:180:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:2014:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `block in call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1788:in `synchronize'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
c:/Ruby200/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
c:/Ruby200/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
c:/Ruby200/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
how could i do to create a testSuite withe an environment document embedded ?

Webbrick shuts down on its own

When I try to lauch webbrick from my terminal using rails server, This is what I get and webbrick shuts down, what could be the problem.
=> Booting WEBrick
=> Rails 4.0.2 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
Following the shutdown I get this huge error which absolutely makes no sense to me.
/Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:229:in `default_controller_and_action': missing :controller (ArgumentError)
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:116:in `normalize_options!'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:64:in `initialize'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1443:in `new'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1443:in `add_route'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1422:in `decomposed_match'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1403:in `block in match'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1394:in `each'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1394:in `match'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:601:in `map_method'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:562:in `get'
from /Users/Fulcrum/Sites/recrea8/config/routes.rb:14:in `block in <top (required)>'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:341:in `instance_exec'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:341:in `eval_block'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:319:in `draw'
from /Users/Fulcrum/Sites/recrea8/config/routes.rb:1:in `<top (required)>'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `block in load'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `each'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:16:in `reload!'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:26:in `block in updater'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.0.2/lib/active_support/file_update_checker.rb:75:in `call'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.0.2/lib/active_support/file_update_checker.rb:75:in `execute'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:27:in `updater'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `run'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:345:in `each'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:345:in `call'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application.rb:215:in `initialize!'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/Fulcrum/Sites/recrea8/config/environment.rb:5:in `<top (required)>'
from /Users/Fulcrum/Sites/recrea8/config.ru:3:in `require'
from /Users/Fulcrum/Sites/recrea8/config.ru:3:in `block in <main>'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
from /Users/Fulcrum/Sites/recrea8/config.ru:in `new'
from /Users/Fulcrum/Sites/recrea8/config.ru:in `<main>'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/commands/server.rb:48:in `app'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/commands/server.rb:75:in `start'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:76:in `block in <top (required)>'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
This is my route.rb
Recrea8::Application.routes.draw do
resources :sessions
resources :users
resources :categories
resources :characters
resources :industries
resources :nationalities
resources :personalities
resources :project_types
resources :projects
get 'logout', 'sessions#destroy', as: 'logout'
match ':controller(/:action(/:id))', :via => [:get, :post]
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
root 'users#new'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
Try to change lines:
#get 'logout', 'sessions#destroy', as: 'logout'
get 'logout' => 'sessions#destroy', as: 'logout'
And
#root 'users#new'
root to: 'users#new'

Resources