I'm getting this error when I am trying to rake data into my application.
I have a JSON file that looks like…
[{"code": "OCH", "name": "blah", "location": "Texas, United States"},…
My db:seeds looks like:
Airport.delete_all
airport_codes = JSON.parse(File.read(Rails.root.join('db/airport_codes.json')))
airport_codes.each do |code|
Airport.create!(code)
end
And my stack trace:
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#swlv/gems/mongoid-3.0.16/lib/mongoid/railties/database.rake:13:in `block (2 levels) in <top (required)>'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/Users/nicholasshook/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/bin/rake:19:in `load'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#global/bin/rake:19:in `<main>'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#swlv/bin/ruby_noexec_wrapper:14:in `eval'
/Users/nicholasshook/.rvm/gems/ruby-1.9.3-p194#swlv/bin/ruby_noexec_wrapper:14:in `<main>'
Thanks!
Hope you have created your rake task like this
task :<rake task name> => :environment do
Airport.delete_all
airport_codes = JSON.parse(File.read(Rails.root.join('db/airport_codes.json')))
airport_codes.each do |code|
Airport.create!(code)
end
end
if this is also correct, then try to include your airport.rb to your rake file
require 'airport.rb'
, but as far as I know above rake task format should work for you
HTH
Related
I'm new to programming and am building a simple wiki sharing app in Ruby on Rails. Every time I try to run rake db:drop, I get this stack trace:
Text file busy - /home/vagrant/code/blocipedia/db/development.sqlite3
/home/vagrant/.rvm/rubies/ruby-2.0.0-p576/lib/ruby/2.0.0/fileutils.rb:1433:in `unlink'
/home/vagrant/.rvm/rubies/ruby-2.0.0-p576/lib/ruby/2.0.0/fileutils.rb:1433:in `block in remove_file'
/home/vagrant/.rvm/rubies/ruby-2.0.0-p576/lib/ruby/2.0.0/fileutils.rb:1438:in `platform_support'
/home/vagrant/.rvm/rubies/ruby-2.0.0-p576/lib/ruby/2.0.0/fileutils.rb:1432:in `remove_file'
/home/vagrant/.rvm/rubies/ruby-2.0.0-p576/lib/ruby/2.0.0/fileutils.rb:785:in `remove_file'
/home/vagrant/.rvm/rubies/ruby-2.0.0-p576/lib/ruby/2.0.0/fileutils.rb:563:in `block in rm'
/home/vagrant/.rvm/rubies/ruby-2.0.0-p576/lib/ruby/2.0.0/fileutils.rb:562:in `each'
/home/vagrant/.rvm/rubies/ruby-2.0.0-p576/lib/ruby/2.0.0/fileutils.rb:562:in `rm'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/activerecord-4.0.10/lib/active_record/tasks/sqlite_database_tasks.rb:22:in `drop'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/activerecord-4.0.10/lib/active_record/tasks/database_tasks.rb:98:in `drop'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/activerecord-4.0.10/lib/active_record/tasks/database_tasks.rb:110:in `block in drop_current'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/activerecord-4.0.10/lib/active_record/tasks/database_tasks.rb:183:in `block in each_current_configuration'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/activerecord-4.0.10/lib/active_record/tasks/database_tasks.rb:182:in `each'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/activerecord-4.0.10/lib/active_record/tasks/database_tasks.rb:182:in `each_current_configuration'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/activerecord-4.0.10/lib/active_record/tasks/database_tasks.rb:109:in `drop_current'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/activerecord-4.0.10/lib/active_record/railties/databases.rake:35:in `block (2 levels) in <top (required)>'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/vagrant/.rvm/rubies/ruby-2.0.0-p576/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/bin/rake:23:in `load'
/home/vagrant/.rvm/gems/ruby-2.0.0-p576/bin/rake:23:in `<main>'
Couldn't drop db/development.sqlite3
any ideas on how to fix this? I've tried running rake db:migrate first, but still end up with the same problem.
I have a custom rake task to evaluate project for Rails Best Practices and Brakeman as follows:
namespace :evaluate do
desc 'Evaluate project for best practices!'
task :best_practices do
path = File.expand_path("../../../", __FILE__)
sh "rails_best_practices #{path}"
end
desc 'Evaluate project with brakeman'
task :brakeman do
sh "brakeman -q -z"
end
desc 'Evaluate everything'
task :everything => [:brakeman, :best_practices]
end
Upon $ rake evaluate:everything the task completes Brakeman successfully but aborts during the rails_best_practices step with the following trace:
Command failed with status (14): [rails_best_practices /Users/admin/projects...]
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/file_utils.rb:54:in `block in create_shell_runner'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/file_utils.rb:45:in `call'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/file_utils.rb:45:in `sh'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/file_utils_ext.rb:37:in `sh'
/Users/admin/projects/bubblin/lib/tasks/security.rake:5:in `block (2 levels) in <top (required)>'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/admin/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/task.rb:201:in `block in invoke_prerequisites'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/task.rb:199:in `each'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/task.rb:199:in `invoke_prerequisites'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
/Users/admin/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/application.rb:106:in `each'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/Users/admin/.rvm/gems/ruby-2.1.1/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/Users/admin/.rvm/gems/ruby-2.1.1/bin/rake:23:in `load'
/Users/admin/.rvm/gems/ruby-2.1.1/bin/rake:23:in `<main>'
/Users/admin/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
/Users/admin/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
I have a feeling this has something to do with my Gemfile, but unable to pinpoint the issue. What could be causing the 'block in create_shell_runner' issue for this rake task?
Thanks in advance!
On a Rails 3.2 application
Gemfile:
gem "state_machine", "~> 1.1.2"
gem 'ruby-graphviz', :require => 'graphviz'
I installed and use with success the state_machine gem, only when I try to draw the state graph
rake state_machine:draw CLASS=Entity
it throws me this error:
** Invoke state_machine:draw (first_time)
** Execute state_machine:draw
** Invoke environment (first_time)
** Execute environment
rake aborted!
uninitialized constant StateMachine::Machine::Constants
/Users/joel/.rvm/gems/ruby-1.9.2-p290#biowatts/gems/state_machine-1.1.2/lib/state_machine/machine.rb:1898:in `draw'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#biowatts/gems/state_machine-1.1.2/lib/state_machine/machine.rb:481:in `block (2 levels) in draw'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#biowatts/gems/state_machine-1.1.2/lib/state_machine/machine.rb:480:in `each_value'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#biowatts/gems/state_machine-1.1.2/lib/state_machine/machine.rb:480:in `block in draw'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#biowatts/gems/state_machine-1.1.2/lib/state_machine/machine.rb:472:in `each'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#biowatts/gems/state_machine-1.1.2/lib/state_machine/machine.rb:472:in `draw'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#biowatts/gems/state_machine-1.1.2/lib/tasks/state_machine.rb:27:in `block (2 levels) in <top (required)>'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/joel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/bin/rake:19:in `load'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/bin/rake:19:in `<main>'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#biowatts/bin/ruby_noexec_wrapper:14:in `eval'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#biowatts/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => state_machine:draw
Any leads on how to troubleshoot this one?
Dirty but works:
unless defined? StateMachine::Machine::Constants::RGV_VERSION
warn "StateMachine::Machine::Constants overriden in #{__FILE__}"
class StateMachine::Machine::Constants
RGV_VERSION = /^[ ]*ruby-graphviz \(([0-9.]+)\)/.match(`cat #{Rails.root.join 'Gemfile.lock'}`)[1]
end
end
To elaborate on tsiruu answer: in case you are using rails, just take his code and put it in an initializer
unless defined? StateMachine::Machine::Constants::RGV_VERSION
warn "StateMachine::Machine::Constants overriden in #{__FILE__}"
class StateMachine::Machine::Constants
RGV_VERSION = /^[ ]*ruby-graphviz \(([0-9.]+)\)/.match(`cat #{Rails.root.join 'Gemfile.lock'}`)[1]
end
end
Hi um quite new to rails and currently working on a task definition in rake file . This is my code
test_task.rake
namespace :test_name_space do
namespace :to do
task :my_task do
p "========================="
sample_out_put = SOutput.new
sample_out_put.createfileoutput
end
end
end
and in my SOutput
class SOutput
def createfileoutput
current_time = Time.new
puts "====================================="
puts "This is a scheduled file output"
puts "====================================="
File.open("/home/kalanamith/Desktop/out.txt", "a+") do |file|
p current_time.inspect.to_s
file.write("This is a sample test")
file.write(current_time.inspect.to_s)
end
end
fileoutput = SOutput.new
fileoutput.createfileoutput
end
and when I run the
rake test_name_space:to:my_task
"========================="
rake aborted!
uninitialized constant SOutput
um getting above error
I dont have a big picture about this error. Can anyone guide me?
/home/kalanamith/Documents/rails_rnd/rails_cron/lib/tasks/test_task.rake:6:in `block (3 levels) in <top (required)>'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
/var/lib/gems/1.9.1/gems/rake-10.0.4/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19:in `<main>'
Tasks: TOP => test_name_space:to:my_task
try adding:
....
task :my_task => :environment do
....
using rails along with mongo-1.8.3, mongoid 3.1.2
i want to combine many string fields and create one full_text index.. but during initial setup i am getting this error
my model looks like this:-
class User
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::FullTextSearch
field :name, type: String
fulltext_search_in :name
getting error on rake db:create_indexes
rake aborted!
undefined method `db' for #<Moped::Collection:0x007fba5c768f18>
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/mongoid_fulltext- 0.5.8/lib/mongoid_fulltext.rb:71:in `fulltext_search_ensure_indexes'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/mongoid_fulltext-0.5.8/lib/mongoid_fulltext.rb:66:in `block in create_fulltext_indexes'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/mongoid_fulltext-0.5.8/lib/mongoid_fulltext.rb:65:in `each_pair'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/mongoid_fulltext-0.5.8/lib/mongoid_fulltext.rb:65:in `create_fulltext_indexes'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/mongoid_fulltext-0.5.8/lib/mongoid_indexes.rb:7:in `create_indexes'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/mongoid-3.1.2/lib/rails/mongoid.rb:21:in `block in create_indexes'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/mongoid-3.1.2/lib/rails/mongoid.rb:18:in `each'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/mongoid-3.1.2/lib/rails/mongoid.rb:18:in `create_indexes'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/mongoid-3.1.2/lib/mongoid/railties/database.rake:71:in `block (3 levels) in <top (required)>'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/Users/akhil/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/bin/rake:23:in `load'
/Users/akhil/.rvm/gems/ruby-1.9.3-p194#rnd/bin/rake:23:in `<main>'
Tasks: TOP => db:mongoid:create_indexes
mongoid_fulltext versions below 0.6 are not compatible with Mongoid 3 (and therefore Moped).
on updating mongoid_fulltext above error went away