kristianmandrup / acts_as_list_mongoid Goto Github PK
View Code? Open in Web Editor NEWMake your Mongoid model acts as a list
Make your Mongoid model acts as a list
First I want to thanks for porting this gem. Whenever I try to us this on a document in my app, I keep receiving the error undefined method 'set_allowed?'
. I've forked your repo and run the tests and am getting the same error. I've tried to trace the stack, reviewing the code in both of your other gems, mongoid_embedded_helper and mongoid_adjust, but I can't seem to figure out where the 'set_allowed?'
method is being called. I'd be happy to try and create a patch if you could point me in the right direction. My app is using rails 3.1.0.rc4
with mongoid 2.0.2
. Thanks!
ruby-1.9.3-p385
mongoid-3.1.2
mongodb version v2.4.0
embedded documents
move(:top) works
# document 'doc' has many embedded documents 'eds'
e = doc.eds.last
e.move(:top)
d.eds.map(&:position)
=> [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1]
doc.reload
doc.eds.map(&:position)
=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
move(:bottom) crashes
doc.eds.map(&:position)
=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
e = doc.eds.first
e.move(:bottom)
# fails. see stacktrace below.
doc.eds.map(&:position)
=> [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
Stacktrace
ArgumentError: wrong number of arguments (0 for 1)
from /Users/oma/.rvm/gems/ruby-1.9.3-p385/gems/mongoid-3.1.2/lib/mongoid/contextual/memory.rb:225:in `sort'
from /Users/oma/.rvm/gems/ruby-1.9.3-p385/gems/mongoid-3.1.2/lib/mongoid/contextual.rb:19:in `sort'
from /Users/oma/.rvm/gems/ruby-1.9.3-p385/gems/acts_as_list_mongoid-0.2.5.1/lib/mongoid/acts_as_list.rb:107:in `order_by_position'
from /Users/oma/.rvm/gems/ruby-1.9.3-p385/gems/acts_as_list_mongoid-0.2.5.1/lib/mongoid/acts_as_list.rb:304:in `bottom_item'
from /Users/oma/.rvm/gems/ruby-1.9.3-p385/gems/acts_as_list_mongoid-0.2.5.1/lib/mongoid/acts_as_list.rb:293:in `bottom_position_in_list'
from /Users/oma/.rvm/gems/ruby-1.9.3-p385/gems/acts_as_list_mongoid-0.2.5.1/lib/mongoid/acts_as_list.rb:309:in `assume_bottom_position'
from /Users/oma/.rvm/gems/ruby-1.9.3-p385/gems/acts_as_list_mongoid-0.2.5.1/lib/mongoid/acts_as_list.rb:193:in `move_to_bottom'
from /Users/oma/.rvm/gems/ruby-1.9.3-p385/gems/acts_as_list_mongoid-0.2.5.1/lib/mongoid/acts_as_list.rb:77:in `move'
from (irb):51
from /Users/oma/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/commands/console.rb:47:in `start'
from /Users/oma/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in `start'
from /Users/oma/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
mongoid_embedded_helper depends on bson which is not used by mongoid 3.x, instead it uses its own MongoDB ruby driver called moped.
It would be great if all that was needed was
include Mongoid::ActsAsList
Then it'd automatically create a position field, and initialize the code without having to call field
yourself or calling acts_as_list
.
Is this possible?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.