gdlx / model_subsets Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Hi and thanks for developing this gem under open source license.
Consider the following model of a rails 3.2 with mongoid 3.0.6:
class Product
include Mongoid::Document
include ModelSubsets
field :name, type: String
field :description, type: String
end
Here are the steps to reproduce the error
DefineI a fieldset on Product
using
fieldset = Product.fieldset :shipping_fields, :length
Create a subset (not really sure what the conceptual difference between fieldset and subset is, guessing from the code that fieldset is more like a class while subset is more like a class instance):
Product.subset :shipping, add: fieldset
create new product instances:
p1 = Product.create! name: 'My Product'
p2 = Product.create! name: 'My Product', length: 20
Query for length on p2 returns 20 (as expected), while query for length on p1 fails with an error:
p1.length
NoMethodError: undefined method `length' for #<Product:0x007fb7848b9640>
from /Users/cblock/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/mongoid-
3.0.6/lib/mongoid/attributes.rb:225:in `method_missing'
Also p1.subset_fields fails with an error (code comments say it returns the current subsets fields list
p1.subset_fields
NameError: undefined local variable or method `subset' for #<Product:0x007fb7848b9640>
from /Users/cblock/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/mongoid-
3.0.6/lib/mongoid/attributes.rb:225:in `method_missing'
Question: Is it me using the gem in a wrong way or is it a bug?
Add-On: How can I restrict subset fields to a certain type or add validations to them?
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.