Rake版本:12.0.0 Ruby:ruby 2.3.0 Rails:Rails 4.2.0
在rake db:reset下运行时的ruby应用程序会给出未定义的方法错误。
rake命令下面没有任何问题。
max-pool-size="20"
但是当我运行rake db:reset时,它会给出以下错误
rake db:drop db:create db:migrate
rake db:schema
rake db:seed
seeds.rb如下。
rake aborted!
NoMethodError: undefined method `misc_info' for #<Venue:0x007ff593140ee8> Did you mean? misc_info_raw
任何帮助将不胜感激
完整错误跟踪:
User .create!([{ first_name: "abc", last_name: "abcd", :email => "ancd@gmail.com", :password => "password", role: 2}]) `
TimeZone.create([
{ :name => "US/Pacific", :created_at => "2013-06-06 22:14:08", :updated_at => "2013-07-09 18:55:41" },
{ :name => "US/Arizona", :created_at => "2014-09-17 03:05:58", :updated_at => "2015-02-02 18:24:38" },
{ :name => "US/Mountain", :created_at => "2013-06-09 22:54:23", :updated_at => "2015-02-02 18:24:49" },
{ :name => "US/Eastern", :created_at => "2013-06-07 00:22:41", :updated_at => "2015-02-02 18:24:57" }
], :without_protection => true )
time_zone = TimeZone.find_by_name("US/Pacific")
Subdivision.create!([
{ :locale1 => "PQDS",
:locale2 => "abcd",
:locale3 => "abcd",
:locale_code => "CA",
:postal_code => "90210",
:country => "United States",
:country_code => "US",
:latitude => 34.1030032,
:longitude => -118.4104684,
:time_zone_id => time_zone.id,
:created_at => "2013-12-17 20:23:52",
:updated_at => "2014-10-02 21:53:06",
:is_visible => true,
:uber_enabled => true }
], :without_protection => true )`
subdivision = Subdivision.find_by_locale3("abcd")
venue = Venue.new({
name: "XXXX",
club_type: 1,
address: "XXX XXXX, XXX, CA",
average_per_bottle: nil,
thumbnail_photo_id: nil,
phone_number: "5554443333",
bt_cut: 25,
music_description: "dsd",
crowd_description: "fffdf",
email: "fdfsf@gmail.com",
braintree_merchant_id: nil,
braintree_verified: false,
score: 0,
active_venue:true,
about: "this place is great",
percent_discount: 0,
subdivision_id: subdivision.id
})
venue.save!
# Create a venue with an initial table section.
# section_image_path = "#{Rails.root}/app/assets/images/dasda.jpeg"
section = Section.new(
location: "Pool Section",
variety: 1,
capacity: 12
)
section.venue = venue
schedule = section.build_schedule
schedule.time = Time.now.utc
schedule.date = Time.now.utc
schedule.rule = "weekly"
schedule.day = ['monday', 'wednesday', 'friday', 'saturday']
section.minimums = {sunday: 5000, monday: 3000, tuesday: 1400, wednesday: 2000, thursday: 3400, friday: 3000, saturday: 4000}
schedule.save!
section.save!
添加models / venue.rb
rake aborted!
NoMethodError: undefined method `misc_info' for #<Venue:0x007f82eb2c88d0>
Did you mean? misc_info_raw
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activemodel-4.2.0/lib/active_model/attribute_methods.rb:433:in `method_missing'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activemodel-4.2.0/lib/active_model/validator.rb:149:in `block in validate'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activemodel-4.2.0/lib/active_model/validator.rb:148:in `each'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activemodel-4.2.0/lib/active_model/validator.rb:148:in `validate'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:450:in `public_send'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:450:in `block in make_lambda'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:189:in `block in simple'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:190:in `block in simple'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:190:in `block in simple'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:190:in `block in simple'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:190:in `block in simple'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:190:in `block in simple'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:190:in `block in simple'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:190:in `block in simple'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:190:in `block in simple'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:190:in `block in simple'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:190:in `block in simple'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:190:in `block in simple'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:190:in `block in simple'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:92:in `_run_callbacks'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:734:in `_run_validate_callbacks'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activemodel-4.2.0/lib/active_model/validations.rb:395:in `run_validations!'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activemodel-4.2.0/lib/active_model/validations/callbacks.rb:113:in `block in run_validations!'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:117:in `call'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:219:in `block in halting_and_conditional'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:92:in `_run_callbacks'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:734:in `_run_validation_callbacks'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activemodel-4.2.0/lib/active_model/validations/callbacks.rb:113:in `run_validations!'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activemodel-4.2.0/lib/active_model/validations.rb:334:in `valid?'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/validations.rb:58:in `valid?'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/validations.rb:83:in `perform_validations'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/validations.rb:43:in `save!'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/transactions.rb:291:in `block in save!'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/transactions.rb:347:in `block in with_transaction_returning_status'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/transactions.rb:220:in `transaction'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/transactions.rb:344:in `with_transaction_returning_status'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/transactions.rb:291:in `save!'
/Users/xxxxxx/Documents/workspace/pk-workspace/pcp-Admin/db/seeds.rb:56:in `<top (required)>'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `block in load'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/engine.rb:547:in `load_seed'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:250:in `load_seed'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:180:in `block (2 levels) in <top (required)>'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
/Users/xxxxxx/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:216:in `block in invoke_prerequisites'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:214:in `each'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:214:in `invoke_prerequisites'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:193:in `block in invoke_with_call_chain'
/Users/xxxxxx/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:139:in `block (2 levels) in <top (required)>'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
/Users/xxxxxx/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/bin/rake:23:in `load'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/bin/rake:23:in `<main>'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
/Users/xxxxxx/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:setup => db:seed
答案 0 :(得分:1)
耙子流产了! NoMethodError:未定义的方法`misc_info'for 地点:0x007ff593140ee8你的意思是? misc_info_raw
正如我所说,您在misc_info
表中缺少venues
列。添加它应该可以解决问题。