migrating to datamapper 0.10.0
June 3rd, 2009 • Uncategorized
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.
17 Responses (Add Your Comment)
-
-
Thank you. Will be good if you add instructions to update merb gems also. Like which branch use and which gems compile.
-
Hey snusnu,
Thanks for the awesome walkthrough in preperation of 0.10.
Just letting you know lines 3&4 of the second source code block should be swapped.
Thanks again
-
appreciate this, thx
-
Thanks for the guide. If I want to revert back to the older (current) version what commands to I need?
I tried reinstalling dm etc but merb says “can’t activate merb-core (= 1.0.12, runtime), already activated merb-core-1.1″
I’m new to rake etc. Did the rake installs tell my system to use 1.1 files? How do I undo this change?
Cheers,
George -
One thing that bit me that wasn’t mentioned is that
belongs_toassociations now default to:nullable => falseinstead of true. -
Roy Wright September 19, 2009at 9:55 pm
When adding to associations, #build is now #new
@comment = @post.comments.build(…)
@comment = @post.comments.new(…)
-
Also, options[:serial]=true has been deprecated in favor of using the Serial type.
The bigger change is to the adapter interface, which doesn’t matter to as many people directly, but could be a problem if you are using some less frequently maintained adapters.
read_one & read_many -> read
with different semantics–read must return an array of either Hashes or Resources.read_one returned a Resource and read_many returned a Collection.
@uri -> @options which makes more sense
The new interface is much cleaner and easier to write against.
-
I hit a wall with this error:
NoMethodError: undefined method `name' for nil:NilClass
Later I discovered through poking at it with irb and googling around, that :child_key is now :target_key and this is what caused the problem. The error is non-obvious.
thanks for the instructions
check line 12 on the first pastie. you need an prepending “../” on the dm-core