Rails migration error - Name can't be blank -


i using rails 2.x version. using mysql 5.0 database end process. faced migration error when did following steps.

  1. get application code github.
  2. run schema:create, load , seed process
  3. after add data in application.
  4. again pull code same branch.
  5. after run db:migrate throws following error
-> rake db:migrate --trace deprecation warning: rake tasks in vendor/plugins/acts_as_audited/tasks, 

vendor/plugins/annotate_models/tasks, vendor/plugins/app_version/tasks, vendor/plugins/bullet/tasks, vendor/plugins/importer/tasks, vendor/plugins/mimetype-fu/tasks, vendor/plugins/railsdav/tasks, vendor/plugins/rav/tasks, vendor/plugins/simple_captcha/tasks, vendor/plugins/smart_table/tasks, vendor/plugins/test_data_generator/tasks, vendor/plugins/visualize_models/tasks, , vendor/plugins/xss_terminate/tasks deprecated. use lib/tasks instead. (called /usr/lib/ruby/gems/1.8/gems/rails-2.3.12/lib/tasks/rails.rb:10)

** invoke db:migrate (first_time) ** invoke environment (first_time) ** execute environmentthu 11 jul 2013 09:24:36 ist ** execute db:migrate ==  convertorganizationtoawesomenestedset: migrating ========================== running sample patched rebuild process. rake aborted! error has occurred, later migrations canceled:  validation failed: name can't blank /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/validations.rb:1102:in 

save_without_dirty!' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/dirty.rb:87:in save_without_transactions!' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/transactions.rb:200:in save!' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in transaction' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/transactions.rb:182:in transaction' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/transactions.rb:200:in save!' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/transactions.rb:208:in rollback_active_record_state!' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/transactions.rb:200:in save!' /opt/sample/lib/awesome_nested_set_overrides.rb:25:in rebuild!' /opt/sample/lib/awesome_nested_set_overrides.rb:22:incall' /opt/sample/lib/awesome_nested_set_overrides.rb:22:in rebuild!' /opt/ssample/lib/awesome_nested_set_overrides.rb:22:ineach' /opt/sample/lib/awesome_nested_set_overrides.rb:22:in rebuild!' /opt/sample/lib/awesome_nested_set_overrides.rb:32:incall' /opt/sample/lib/awesome_nested_set_overrides.rb:32:in rebuild!' /opt/sample/lib/awesome_nested_set_overrides.rb:29:ineach' /opt/sample/lib/awesome_nested_set_overrides.rb:29:in rebuild!' ./db/migrate//20130102220216_convert_organization_to_awesome_nested_set.rb:6:in up_without_benchmarks' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/migration.rb:282:in send' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/migration.rb:282:in migrate' /usr/lib/ruby/1.8/benchmark.rb:293:in measure' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/migration.rb:282:in migrate' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/migration.rb:365:in __send__' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/migration.rb:365:in migrate' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/migration.rb:491:in migrate' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/migration.rb:567:in call' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/migration.rb:567:in ddl_transaction' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/migration.rb:490:in migrate' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/migration.rb:477:in each' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/migration.rb:477:in migrate' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/migration.rb:401:in up' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/migration.rb:383:in migrate' /usr/lib/ruby/gems/1.8/gems/rails-2.3.12/lib/tasks/databases.rake:112 /usr/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:228:in call' /usr/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:228:inexecute' /usr/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:223:in each' /usr/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:223:inexecute' /usr/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:166:in invoke_with_call_chain' /usr/lib/ruby/1.8/monitor.rb:242:insynchronize' /usr/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:159:in invoke_with_call_chain' /usr/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:152:ininvoke' /usr/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:143:in invoke_task' /usr/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:101:in top_level' /usr/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:101:in each' /usr/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:101:in top_level' /usr/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:110:in run_with_threads' /usr/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:95:in top_level' /usr/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:73:in run' /usr/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:160:in standard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:70:in run' /usr/lib/ruby/gems/1.8/gems/rake-10.0.3/bin/rake:33 /usr/bin/rake:19:inload' /usr/bin/rake:19 tasks: top => db:migrate

organization.rebuild! - code calls plugin.

it seems there problem awesome_nested_set plugin. struggle past 1 week. comments appreciated.

edit - 1

class convertorganizationtoawesomenestedset < activerecord::migration  def self.up     #  add_column :party, :lft, :integer  #  add_column :party, :rgt, :integer       organization.reset_column_information       organization.rebuild!   end    def self.down       remove_column :party, :lft       remove_column :party, :rgt   end end 

model - organization

class organization < party attr_accessible :name,                    :parent_id     default_scope :order => 'name'     acts_as_nested_set has_many :children, :class_name => 'organization',  :foreign_key => "parent_id"     belongs_to :parent, :class_name =>'organization', :foreign_key => "parent_id"     def display_name      name      end 

you using activerecord model class in migration. in short: don't.

this cause problems in long run. if have migration uses model class, , run again later on, you'll in trouble if changes model class.

migrations strictly setting database, , should constructed behave in same way - regardless of current state of app's code is.

if need migration activerecord model: define class inside migration file. way immutable changes rest of app.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -