datamapper / dm-is-remixable Goto Github PK
View Code? Open in Web Editor NEWdm-is-remixable allow you to create reusable data functionality
Home Page: http://datamapper.org/
License: MIT License
dm-is-remixable allow you to create reusable data functionality
Home Page: http://datamapper.org/
License: MIT License
I'm receiving strange error when I have Float property in module.
module Comment
include DataMapper::Resource
is :remixable
property :id, Serial
property :vote, Floar
end
class Post
include DataMapper::Resource
...
remix 1, :comments
end
the stack trace is
/Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/property.rb:780:in `each': +options[:scale]+ should be Integer, but was NilClass (ArgumentError)
from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/property.rb:780:in `assert_valid_options'
from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/property.rb:743:in `initialize'
from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/property/numeric.rb:16:in `initialize'
from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/model/property.rb:55:in `new'
from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/model/property.rb:55:in `property'
from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-validations-1.2.0/lib/dm-validations/auto_validate.rb:11:in `property'
from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@nutri/gems/dm-is-remixable-1.2.0/lib/dm-is-remixable/is/remixable.rb:385:in `block in generate_remixed_model'
from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/support/subject_set.rb:210:in `block in each'
from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/support/ordered_set.rb:319:in `block in each'
from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/support/ordered_set.rb:319:in `each'
from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/support/ordered_set.rb:319:in `each'
from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@global/gems/dm-core-1.2.0/lib/dm-core/support/subject_set.rb:210:in `each'
from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@nutri/gems/dm-is-remixable-1.2.0/lib/dm-is-remixable/is/remixable.rb:384:in `generate_remixed_model'
from /Users/carlospereira/.rvm/gems/ruby-1.9.2-p320@nutri/gems/dm-is-remixable-1.2.0/lib/dm-is-remixable/is/remixable.rb:188:in `remix'
I'm using DM v 1.2.0
Any idea?
Thank you
Hi,
I try to run the example code in the README.rdoc and found it failed from dm-core:
/usr/local/Cellar/ruby-enterprise-edition/2010.02/lib/ruby/gems/1.8/gems/dm-core-1.0.2/lib/dm-core/associations/relationship.rb:173:in `target_model': Cannot find the child_model VideoCommentVotes for User in video_comment_votes (NameError)
The code actually used is here: http://gist.github.com/582753
If I change line 85 to remix n
like:
remix n, :votes, :for => "User"
Then it worked. The migration is finished and the created tables seems to be correct for me.
I discovered this when I was playing with dm-is-remixable and remix 1
was never working in there. It was a direct, non-nested remix.
dm-is-remixable does not allow belong_to relations (and I guess, but haven't tested, neither has-1/n relations). Is that by design?
Workaround is to use enhance at the places where you remix the remixable, but that is quite repetitive.
Created by Lawrence Pit - 2008-10-24 11:36:07 UTC
Original Lighthouse ticket: http://datamapper.lighthouseapp.com/projects/20609/tickets/612
After doing a simple dm-is-remixable example, I noticed that no class-methods were added to the model for the new relationship. Instance methods were added for the relationship.
I believe that the ability to remix 1 should behave differently. According to the documentation from the remix 1, :addressables
example found on the README the Location being remixed with 1 address does the following:
However when inspecting the database it appears that multiple addresses can technically be applied to 1 location. I'm proposing the following behavior:
location_id
If activesupport isn't present, dm-is-remixable fails with:
dm-is-remixable-1.0.2/lib/dm-is-remixable/is/remixable.rb:71:in is_remixable': uninitialized constant ActiveSupport::Inflector (NameError) from dm-core-1.0.2/lib/dm-core/model/is.rb:23:in
is'
[...]
extlib (which is installed) seems to include an inflector, but dm-is-remixable doesn't bring it in like dm-core and dm-validations do?
Here's a simple testcase:
require 'rubygems'
require 'dm-core'
# See issue 8 for why I'm doing this
require 'extlib/inflection'
module ActiveSupport
Inflector = ::Extlib::Inflection
end
require 'dm-is-remixable'
module Test
module Foo
include DataMapper::Resource
is :remixable
property :id, Serial
end
class WorkingFoo
include DataMapper::Resource
property :id, Serial
property :bar_id, Integer
end
class Bar
include DataMapper::Resource
property :id, Serial
has n, :working_foos # Works
remix n, :foos # Doesn't work
end
end
I get:
NameError: uninitialized constant Foo
from dm-core-1.0.2/lib/dm-core/core_ext/object.rb:13:in full_const_get' from dm-core-1.0.2/lib/dm-core/core_ext/object.rb:10:in
each'
from dm-core-1.0.2/lib/dm-core/core_ext/object.rb:10:in full_const_get' from dm-is-remixable-1.0.2/lib/dm-is-remixable/is/remixable.rb:160:in
remix'
It might actually be a bug in dm-core, I guess (since we're using full_const_get) - but the has n, :working_foos doesn't raise in the same manner.
There is probably a better way of handling the lack of String#underscore
when using extlib
.
I noticed that dm-is-remixable searches for models at the top-level first. This differs from how dm-core resolves models, which begins searching in the current namespace upward.
# lib/dm-is-remixable/is/remixable.rb:60
remixable_module = case remixable
when Symbol then Object.full_const_get(ActiveSupport::Inflector. classify(remixable))
when String then Object.full_const_get(remixable)
when Module then remixable
end
Given the following
class Person
include DataMapper::Resource
property :id, Serial
property :name, String
remix n, :addresses
end
module Address
include DataMapper::Resource
is :remixable
property :id, Serial
property :city, String
end
When I run
rake db:automigrate,
Then, instead of getting a table called person_addresses,
it's called person_addres, not at all what I expected.
Looks like a pluralization issue? So far its the only model I have with this problem.
Also no matter what I do (on any model), remix n ignores the :as key (by ignore I mean that the table names are not affected, I'm unsure if that's the intended behavior)
Upgrading a new application to 3.1/1.2.0.rc1
This only appears when using dm-is-remixable is installed
rake db:automigrate --trace
rake aborted!
uninitialized constant Extlib::Inflection
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/ext/module.rb:36:in `const_missing'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/dm-is-remixable-0.10.0/lib/dm-is-remixable/is/remixable.rb:10:in `<top (required)>'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/dm-is-remixable-0.10.0/lib/dm-is-remixable.rb:1:in `require'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/dm-is-remixable-0.10.0/lib/dm-is-remixable.rb:1:in `<top (required)>'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `require'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `each'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `block in require'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `each'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `require'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.18/lib/bundler.rb:120:in `require'
/media/essential/projects/1_current/thrisp/modules/+velicessegia/ticketenginealpha/config/application.rb:13:in `<top (required)>'
/home/qx/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/qx/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/media/essential/projects/1_current/thrisp/modules/+velicessegia/ticketenginealpha/Rakefile:5:in `<top (required)>'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:495:in `raw_load_rakefile'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:78:in `block in load_rakefile'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:77:in `load_rakefile'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:61:in `block in run'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/home/qx/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/home/qx/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `load'
/home/qx/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `<main>'
dm-is-remixable still uses the old RDoc style documentation.
I've just started working with trying to create different repositories, and I haven't been able to get remixed models to inherit the repository, or change the repository from :default
Using this:
https://gist.github.com/1278627
I can specify a repository for the Ticket model, but TicketComments can not be changed from the methods I've tried. The expected behavior should be for remixed models to inherit the repository of the models remixed from, i.e. TicketComments should inherit the repository of Ticket, but this may be my opinion in this case and I can see where it might not always be the case.
I'm probably missing the obvious method, but going through several times from various directions resulted in no change.
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.