I found another similar question and think I'm following the referenced directions from here but am still coming across this error.
As per the instructions I'm calling Mongoid.load!("path/to/your/mongoid.yml") in my ruby script, so I don't think it's that.
Maybe, as per the error message coming from inflector, it's an issue with how I'm defining CarrierDomain. I'm referencing a rails model from the Sinatra script. It's in a model file called carrier_domain.rb and the class is defined as CarrierDomain (class CarrierDomain). In fact, here is the entire class definition (it's a little one):
class CarrierDomain
include Mongoid::Document
embedded_in :carrier
field :country
field :name
field :prefix, default: ''
end
Here's the error message I'm getting:
/Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:230:in `block in constantize': uninitialized constant CarrierDomain (NameError)
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `constantize'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/metadata.rb:606:in `klass'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/builder.rb:39:in `klass'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/builders/embedded/many.rb:25:in `block in build'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/builders/embedded/many.rb:23:in `each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/builders/embedded/many.rb:23:in `build'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/accessors.rb:43:in `create_relation'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/accessors.rb:26:in `__build__'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/accessors.rb:156:in `block (3 levels) in getter'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/threaded/lifecycle.rb:125:in `_loading'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/accessors.rb:156:in `block (2 levels) in getter'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/threaded/lifecycle.rb:84:in `_building'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/relations/accessors.rb:155:in `block in getter'
from /opt/cmf/app/models/carrier.rb:120:in `to_email_addresses'
from mta_connector.rb:151:in `block in <main>'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/contextual/mongo.rb:645:in `yield_document'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/contextual/mongo.rb:134:in `block (2 levels) in each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/moped-1.2.7/lib/moped/query.rb:78:in `block in each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/moped-1.2.7/lib/moped/cursor.rb:26:in `block in each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/moped-1.2.7/lib/moped/cursor.rb:26:in `each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/moped-1.2.7/lib/moped/cursor.rb:26:in `each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/moped-1.2.7/lib/moped/query.rb:77:in `each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/moped-1.2.7/lib/moped/query.rb:77:in `each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/contextual/mongo.rb:133:in `block in each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/contextual/mongo.rb:604:in `selecting'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/contextual/mongo.rb:132:in `each'
from /Users/arigold/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-3.0.10/lib/mongoid/contextual.rb:18:in `each'
from mta_connector.rb:139:in `<main>'
I had to explicitly require 'carrier_domain' in my Sinatra script.
I had thought that it would know to get the file, since it worked in the rails console (that is, I didn't need to require it in the rails console). Hmm.
Anyhoo, adding require 'carrier_domain' (i.e. the uninitialized constant) to my Sinatra script worked.
Related
I've been doing testing with this tool to migrate data from mongo db and this one of the issue that I have yet to find out a solution... been wondering a while looking for a solution... but there's no clear solution until now. Please find the stack trace below..
mosql version unknown (but when I try to uninstall the mosql, it mentions the version of mosql-0.4.3
ruby version: ruby 2.2.4p230 (2015-12-16 revision 53155) [x64-mingw32]
I made a changes to cli.rb under this folder C:\Ruby22-x64\lib\ruby\gems\2.2.0\gems\mosql-0.4.3\lib\mosql to delete "USR2" at line 27 from the list to fix issue of running mosql.
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:1252:in `literal_other_append': can't express BSON::ObjectId('5656805534616f4c317b7bff') as a SQL literal (Sequel::Error)
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:108:in `literal_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:486:in `complex_expression_sql_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/adapters/shared/postgres.rb:1272:in `complex_expression_sql_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/sql.rb:109:in `to_s_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:1214:in `literal_expression_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:86:in `literal_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:494:in `block in complex_expression_sql_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:492:in `each'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:492:in `complex_expression_sql_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/adapters/shared/postgres.rb:1272:in `complex_expression_sql_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/sql.rb:109:in `to_s_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:1214:in `literal_expression_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:1229:in `literal_hash_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:84:in `literal_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/extensions/pg_array.rb:504:in `block in _literal_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/extensions/pg_array.rb:499:in `each'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/extensions/pg_array.rb:499:in `_literal_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/extensions/pg_array.rb:483:in `sql_literal_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:1248:in `literal_other_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:108:in `literal_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:1576:in `block in update_sql_values_hash'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:1568:in `each'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:1568:in `update_sql_values_hash'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:1559:in `update_set_sql'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:229:in `_update_sql'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:175:in `update_sql'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/actions.rb:818:in `update'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/sql.rb:59:in `upsert!'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:61:in `block (2 levels) in bulk_upsert'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:39:in `unsafe_handle_exceptions'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:60:in `block in bulk_upsert'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:57:in `each'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:57:in `rescue in bulk_upsert'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:52:in `bulk_upsert'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:164:in `import_collection'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:122:in `block (2 levels) in initial_import'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:120:in `each'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:120:in `block in initial_import'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:108:in `each'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:108:in `initial_import'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:28:in `import'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/cli.rb:167:in `run'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/cli.rb:16:in `run'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/bin/mosql:5:in `<top (required)>'
from C:/Ruby22-x64/bin/mosql:22:in `load'
from C:/Ruby22-x64/bin/mosql:22:in `<main>'
You probably want to add an #sql_literal or #sql_literal_append method to BSON::ObjectId so that Sequel knows how to literalize it.
I'm trying to monkey patch Object and while my tests run fine,
I can't load my project with Pry anymore.
Here is the relevant code:
module CoreExtensions
def instance_values
instance_variables.each_with_object({}) do |var, hash|
hash[var[1..-1]] = instance_variable_get(var)
end
end
def ==(other)
(self.class == other.class) &&
(instance_values.equal? other.instance_values)
end
end
Object.include CoreExtensions
Using
pry -r ./core_extentions.rb
leads to this stacktrace:
Error: No live threads left. Deadlock?
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:87:in `sleep'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:87:in `wait'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:87:in `block in enter_interruptible_region'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:83:in `synchronize'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:83:in `enter_interruptible_region'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:110:in `interruptible_region'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:197:in `input_readline'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:190:in `block in read_line'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:129:in `handle_read_errors'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:170:in `read_line'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:98:in `read'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:68:in `block in repl'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:67:in `loop'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:67:in `repl'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:38:in `block in start'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:61:in `__with_ownership'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/input_lock.rb:79:in `with_ownership'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:38:in `start'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/repl.rb:15:in `start'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/pry_class.rb:169:in `start'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-byebug-3.3.0/lib/pry-byebug/pry_ext.rb:11:in `start_with_pry_byebug'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/cli.rb:219:in `block in <top (required)>'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/cli.rb:83:in `block in parse_options'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/cli.rb:83:in `each'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/lib/pry/cli.rb:83:in `parse_options'
/home/fap/.rvm/gems/ruby-2.3.0/gems/pry-0.10.3/bin/pry:16:in `<top (required)>' /home/fap/.rvm/gems/ruby-2.3.0/bin/pry:23:in `load'
/home/fap/.rvm/gems/ruby-2.3.0/bin/pry:23:in main
/home/fap/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
/home/fap/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in main
The same thing happens when I include my CoreExtentions in the main class.
I read about Pry's input_lock, but I don't understand what produces the deadlock.
Does anyone have an idea why this is happening?
You have redefined method == for all objects, which is not a good thing.
This comes about from the last line in your question, namely Object.include CoreExtentions
Without that definition, it loads fine.
I have migration 20150930051523_create_objects.rb:
class CreateObjects < ActiveRecord::Migration
def change
create_table :objects do |t|
t.text :name
t.timestamps null: false
end
Object.create :name => "A"
Object.create :name => "B"
Object.create :name => "C"
end
end
$ rake:db migrate --trace cause output:
** Invoke db:migrate (first_time)
** Invoke db:environment (first_time)
** Execute db:environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
== 20150930051523 CreateObjects: migrating ====================================
-- create_table(:objects)
-> 0.0010s
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
uninitialized constant CreateObjects::Object/db/migrate/20150930051523_create_objects.rb:8:in `change'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:605:in `exec_migration'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:589:in `block (2 levels) in migrate'
/usr/lib/ruby/2.1.0/benchmark.rb:279:in `measure'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:588:in `block in migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:587:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:765:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:995:in `block in execute_migration_in_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:1041:in `block in ddl_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/transactions.rb:220:in `transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:1041:in `ddl_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:994:in `execute_migration_in_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:956:in `block in migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:952:in `each'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:952:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:820:in `up'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:798:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in '
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/var/lib/gems/2.1.0/gems/rake-10.4.2/bin/rake:33:in `'
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `'
NameError: uninitialized constant CreateObjects::Object/db/migrate/20150930051523_create_barbers.rb:8:in `change'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:605:in `exec_migration'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:589:in `block (2 levels) in migrate'
/usr/lib/ruby/2.1.0/benchmark.rb:279:in `measure'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:588:in `block in migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:587:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:765:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:995:in `block in execute_migration_in_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:1041:in `block in ddl_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/transactions.rb:220:in `transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:1041:in `ddl_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:994:in `execute_migration_in_transaction'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:956:in `block in migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:952:in `each'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:952:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:820:in `up'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:798:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in '
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/var/lib/gems/2.1.0/gems/rake-10.4.2/bin/rake:33:in `'
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `'
Tasks: TOP => db:migrate
Error emerging at Object.create... stage, what is wrong?
Update: In a comment it was pointed out that the actual code was not containing "Object", this answer is thus based on the wrong example.
Object is a bad name to use for an (unscoped) Model class, as it is already defined by Ruby.
The Object you are calling create on is probably not the Object class you defined in your model sources.
I assume you run rails. Remove the Object.create lines from your migration. Run it, it should work fine. Then, call rails console, where you end up in a live session. Here you can play around with your code, e.g. call Object.create, Object.where{id: 1} etc. I assume that you will get the same errors.
So, as a solution, rename your Object into something else, like Class and look if it works.
Okay, that was a joke, of course Class is also a really bad name for a model class :) . Try to find something more meaningful.
The problem was solved by set up pg gem, which pull bundle of another gems and packs (particularly postgresql-server-dev-all). After installing it, the command rake db:migrate works fine and completely.
I'm randomly getting the following error message. Does anyone have any ideas what could be causing this?
NoMethodError (undefined method `slice!' for nil:NilClass):
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/connection/ruby.rb:274:in `read'
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:248:in `block in read'
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:236:in `io'
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:247:in `read'
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:112:in `block in call'
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:217:in `block (2 levels) in process'
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:353:in `ensure_connected'
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:207:in `block in process'
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:292:in `logging'
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:206:in `process'
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:112:in `call'
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis.rb:789:in `block in get'
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis.rb:37:in `block in synchronize'
/usr/local/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis.rb:37:in `synchronize'
vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis.rb:788:in `get'
vendor/bundle/ruby/2.1.0/gems/redis-store-1.1.4/lib/redis/store/interface.rb:5:in `get'
vendor/bundle/ruby/2.1.0/gems/redis-store-1.1.4/lib/redis/store/marshalling.rb:17:in `get'
vendor/bundle/ruby/2.1.0/gems/redis-activesupport-4.0.0/lib/active_support/cache/redis_store.rb:169:in `read_entry'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.9/lib/active_support/cache.rb:312:in `block in read'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.9/lib/active_support/cache.rb:548:in `instrument'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.9/lib/active_support/cache.rb:311:in `read'
/var/www/apps/13712/shared/vendor_bundle/ruby/2.1.0/bundler/gems/spree-13f1df56d58f/core/app/models/spree/preferences/store.rb:34:in `get'
/var/www/apps/13712/shared/vendor_bundle/ruby/2.1.0/bundler/gems/spree-13f1df56d58f/core/app/models/spree/preferences/scoped_store.rb:13:in `fetch'
/var/www/apps/13712/shared/vendor_bundle/ruby/2.1.0/bundler/gems/spree-13f1df56d58f/core/app/models/spree/preferences/preferable_class_methods.rb:13:in `block in preference'
/var/www/apps/13712/shared/vendor_bundle/ruby/2.1.0/bundler/gems/spree-13f1df56d58f/core/app/models/spree/preferences/preferable.rb:43:in `get_preference'
vendor/bundle/ruby/2.1.0/bundler/gems/spree-13f1df56d58f/core/lib/spree/core/controller_helpers/ssl.rb:8:in `block (2 levels) in <module:SSL>'
The last place Spree is hit before calling redis-rb:
unless (val = #cache.read(key)).nil?
return val
end
where #cache = Rails.cache
UPDATE
I am using this gem with this SSL plugin, so the error may be related to the plugin.
The error happens when line = #sock.gets is nil. Here's the locals right after that is determined to be true.
[1] pry(#<Redis::Connection::Ruby>)> line
=> nil
[2] pry(#<Redis::Connection::Ruby>)> #sock
=> #<OpenSSL::SSL::SSLSocket:0x007fdab2688730
#callback_state=nil,
#context=
#<OpenSSL::SSL::SSLContext:0x007fdab2688758
#ca_file=nil,
#ca_path=nil,
#cert=nil,
#cert_store=nil,
#client_ca=nil,
#client_cert_cb=nil,
#extra_chain_cert=nil,
#key=nil,
#npn_protocols=nil,
#npn_select_cb=nil,
#options=nil,
#renegotiation_cb=nil,
#servername_cb=nil,
#session_get_cb=nil,
#session_id_context=nil,
#session_new_cb=nil,
#session_remove_cb=nil,
#timeout=nil,
#tmp_dh_callback=nil,
#verify_callback=nil,
#verify_depth=nil,
#verify_mode=nil>,
#eof=true,
#hostname=nil,
#io=#<Redis::Connection::TCPSocket:fd 11>,
#rbuffer="",
#sync=true,
#sync_close=false,
#wbuffer="">
[3] pry(#<Redis::Connection::Ruby>)> #sock.closed?
=> false
This looks like this could be an issue with the ruby redis client.
You could try downgrading a version and/or filing an issue for the redis team in the Github repository.
Okay so this is a new one. RSPec. Rails 4.
This line is in my spec_helper.rb:
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
When I run a simple test (on an ActiveRecord model):
it { should respond_to :activity }
I get the following error & trace:
/Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord 4.0.0/lib/active_record/attribute_methods.rb:59:in `instance_method_already_implemented?': version is defined by Active Record (ActiveRecord::DangerousAttributeError)
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activemodel-4.0.0/lib/active_model/attribute_methods.rb:282:in `block in define_attribute_method'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activemodel-4.0.0/lib/active_model/attribute_methods.rb:279:in `each'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activemodel-4.0.0/lib/active_model/attribute_methods.rb:279:in `define_attribute_method'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activemodel-4.0.0/lib/active_model/attribute_methods.rb:246:in `block in define_attribute_methods'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activemodel-4.0.0/lib/active_model/attribute_methods.rb:246:in `each'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activemodel-4.0.0/lib/active_model/attribute_methods.rb:246:in `define_attribute_methods'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/attribute_methods.rb:29:in `block in define_attribute_methods'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/attribute_methods.rb:26:in `synchronize'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/attribute_methods.rb:26:in `define_attribute_methods'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/attribute_methods.rb:167:in `respond_to?'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:368:in `__define_callbacks'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:79:in `run_callbacks'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/core.rb:216:in `init_with'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/persistence.rb:55:in `instantiate'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/querying.rb:45:in `block in find_by_sql'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/result.rb:21:in `block in each'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/result.rb:21:in `each'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/result.rb:21:in `each'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/querying.rb:45:in `map'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/querying.rb:45:in `find_by_sql'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/relation.rb:585:in `exec_queries'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/relation.rb:471:in `load'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/relation.rb:220:in `to_a'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/relation/delegation.rb:12:in `map'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/migration.rb:787:in `get_all_versions'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/migration.rb:793:in `current_version'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/migration.rb:800:in `needs_migration?'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/migration.rb:379:in `check_pending!'
from /projects/subset_of_projects/this_project_group/projectname/spec/spec_helper.rb:17:in `<top (required)>'
I'd added the paper_trail gem but not run the install/migrations. Simple and obvious really. But it wasn't an error I'd seen before so I'll post this so others who might run into it can check the obvious before wasting a long time on this.