Archive for June, 2009
inspecting a many_to_many datamapper relationship object
June 25th, 2009 •
tags: datamapper, ruby
The output of calling inspect on a datamapper many_to_many relationship object is very informative
migrating to datamapper 0.10.0
June 3rd, 2009 •
17 comments
tags: datamapper, ruby
Some prerequisites to get ready for datamapper 0.10.0
You need to have at least rubygems 1.3.5
You need to have a reasonably fresh rspec
The following git instructions only apply if you want to keep track of the ongoing datamapper development.
You can safely omit them if you followed the instructions in the original post to the google group.
sudo gem install addressable mkdir git-sources cd git-sources/ git clone git://github.com/datamapper/extlib.git git clone git://github.com/datamapper/do.git git clone git://github.com/datamapper/dm-core.git git clone git://github.com/datamapper/dm-more.git git clone git://github.com/snusnu/merb.git cd extlib/ rake install cd .. cd do/data_objects/ rake install cd ../do_sqlite3/ rake install cd ../do_xxx/ rake install cd ../.. cd dm-core/ rake install cd .. cd dm-more/ rake install cd ..
Migrating your app to datamapper 0.10.0 is pretty painless,
you mainly need to deal with deprecation notices:
options[:class_name] is now options[:model]
PropertySet#has_property? is now PropertySet#named?
update_attributes is now update and doesn’t support the *allow_attributes parameter anymore
new_record? is now new?
:mutable => true on a has(n, :things, :through => :others) relationship is not supported/necessary anymore
:remote_name option for has(n, :things, :through => :others) is now called :via
:some_property.in => ['val1', 'val2'] is not supported anymore in queries, just use :some_property => ['val1', 'val2']
belongs_to :parent now defaults to :nullable => false
When adding to associations, post.comments.build(...) is now post.comments.new(...)
If you’re using merb and you’re fine using the master branch (upcoming merb-1.1) and not the latest release, all you need to do is update your wycats/merb clone or run the following commands.
cd git-sources/ git clone git://github.com/wycats/merb.git cd merb sudo rake install
If you however want to use datamapper 0.10.0 with latest merb release (1.0.12 at the time of writing) you will currently need to run these commands (Thx again teamon for taking the time to backport stuff!).
merb-1.0.13 will be released soon and will be fully compatible with datamapper 0.10.0.
cd git-sources/ git clone git://github.com/wycats/merb.git cd merb git checkout -b 1.0.x --track origin/1.0.x sudo rake install
You will maybe get some warnings about merb-more but you can safely ignore them.