-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
I have Mongoid from the 'master' branch and with Rails 4.1.0.beta1, Just caught up with an error -
rake aborted! (eval):2: syntax error, unexpected end-of-input, expecting keyword_end /Users/hasan/.rvm/gems/ruby-2.0.0-p0@venue-platform/gems/activesupport-4.1.0.beta1/lib/active_support/core_ext/kernel/singleton_class.rb:4:in `class_eval' /Users/hasan/.rvm/gems/ruby-2.0.0-p0@venue-platform/gems/activesupport-4.1.0.beta1/lib/active_support/core_ext/kernel/singleton_class.rb:4:in `class_eval' /Users/hasan/.rvm/gems/ruby-2.0.0-p0@venue-platform/bundler/gems/mongoid-221abac035d4/lib/mongoid/interceptable.rb:258:in `run_targeted_callbacks' /Users/hasan/.rvm/gems/ruby-2.0.0-p0@venue-platform/bundler/gems/mongoid-221abac035d4/lib/mongoid/interceptable.rb:107:in `block in run_before_callbacks' /Users/hasan/.rvm/gems/ruby-2.0.0-p0@venue-platform/bundler/gems/mongoid-221abac035d4/lib/mongoid/interceptable.rb:106:in `each' /Users/hasan/.rvm/gems/ruby-2.0.0-p0@venue-platform/bundler/gems/mongoid-221abac035d4/lib/mongoid/interceptable.rb:106:in `run_before_callbacks' /Users/hasan/.rvm/gems/ruby-2.0.0-p0@venue-platform/bundler/gems/mongoid-221abac035d4/lib/mongoid/relations/embedded/batchable.rb:273:in `block in pre_process_batch_insert' /Users/hasan/.rvm/gems/ruby-2.0.0-p0@venue-platform/bundler/gems/mongoid-221abac035d4/lib/mongoid/relations/embedded/batchable.rb:267:in `map' /Users/hasan/.rvm/gems/ruby-2.0.0-p0@venue-platform/bundler/gems/mongoid-221abac035d4/lib/mongoid/relations/embedded/batchable.rb:267:in `pre_process_batch_insert' /Users/hasan/.rvm/gems/ruby-2.0.0-p0@venue-platform/bundler/gems/mongoid-221abac035d4/lib/mongoid/relations/embedded/batchable.rb:131:in `execute_batch_insert' /Users/hasan/.rvm/gems/ruby-2.0.0-p0@venue-platform/bundler/gems/mongoid-221abac035d4/lib/mongoid/relations/embedded/batchable.rb:88:in `batch_replace' /Users/hasan/.rvm/gems/ruby-2.0.0-p0@venue-platform/bundler/gems/mongoid-221abac035d4/lib/mongoid/relations/embedded/many.rb:293:in `substitute' /Users/hasan/.rvm/gems/ruby-2.0.0-p0@venue-platform/bundler/gems/mongoid-221abac035d4/lib/mongoid/relations/accessors.rb:234:in `block (2 levels) in setter' /Users/hasan/.rvm/gems/ruby-2.0.0-p0@venue-platform/bundler/gems/mongoid-221abac035d4/lib/mongoid/relations/accessors.rb:140:in `without_autobuild' /Users/hasan/.rvm/gems/ruby-2.0.0-p0@venue-platform/bundler/gems/mongoid-221abac035d4/lib/mongoid/relations/accessors.rb:232:in `block in setter'
I have the following models -
module Backend class Artist include Mongoid::Document include Mongoid::Timestamps # Fields... has_many :status_collections, class_name: 'Backend::StatusCollection', foreign_key: 'user_id' end end
`
module Backend class StatusCollection include Mongoid::Document include Mongoid::Timestamps # Fields... embeds_many :statuses, class_name: 'Backend::Status' belongs_to :artist, class_name: 'Backend::Artist', foreign_key: 'user_id' validates :source, presence: true, uniqueness: { scope: [:artist_id] } end end
`
This is what I was trying to do.
status_collection = ...
status_collection.statuses = 4.times.map { Backend::Status.new }
# Then it threw those error
After few investigation, it looks like mongoid was expecting a string from ActiveSupport::Callbacks::CallbackChain#compile from this line - https://github.com/mongoid/mongoid/blob/master/lib/mongoid/interceptable.rb#L258
But this code is changed in latest rails (looks like this change is here for more than 8 months) here is code pointer - https://github.com/rails/rails/blob/ade7d365e434b586a4c1747d917beb986cb35fc7/activesupport/lib/active_support/callbacks.rb#L381
Let me know if you need any more information.