[PATCH] rails_datamapper get it to run with rails 2.3.0
Reported by kristian | February 22nd, 2009 @ 11:12 AM
rails_datamapper gave me a few problems: * Rails.root always gives an empty string * DataMapper.rake did not load the model files for automigrate/autoupgrade * the model generator did not generate my properties
the attached patch solves these little problems
Comments and changes to this ticket
I think DM Rails plugin must be 100% "free" from AR specific code, and not only because it lets you save on memory: less loaded code means less interdependencies that may break or interfere. Unless some members of the Rails community stops abusing aliasing and finally recalls Ruby is a damn pure OO language, less dependencies = less possible breakages.
But of course, this may happen eventually and not next week. Agnosticism of Rails is a still largely a work in progress because minds do not change over night.
The weird thing I can't understand from the patch is why ActiveRecord is require'd at all? If you really wanted AR, there's a configuration option you'd use to load it.
This makes me think that either: a) there's some reason for it that is not obvious when viewing the code, or b) it was added as part of some other debugging that was happening, and kristian just forgot to remove it. I think "b" is the most likely case.
If someone is using rails_datamapper with a Rails project, would you mind running some tests with this code taken out? If not, then I'll spin up a Rails project in the next week or so and give it a shot testing it. (I'm working like crazy trying to get dm-core 0.10 ready, or even close to ready, for RailsConf, otherwise I'd do it now myself)
I tried removing the require line from the generator but the generator would not work without it:
arthur-carlssons-macbook-pro:appengine-test-app arthur$ jruby -S script/generate dm_model -p person
exists app/models/ exists test/unit/ create app/models/person.rb create test/unit/person_test.rb exists db/migrate
uninitialized constant Rails::Generator::Commands::Base::ActiveRecord
Does the ModelGenerator class have a dependency to ActiveRecord? I haven't checked it out...
However, I don't think it's that big deal since it's just in the generator that this dependency exists. It won't affect the application in any other way.
- State changed from resolved to accepted
Is there a way to make it so when using rails_datamapper the --skip-migration option is the default?
Or alternatively, would it be possible to create a Rails::Generator::Commands::Base::DataMapper namespace, and copy it to Rails::Generator::Commands::Base::ActiveRecord when it doesn't exist? We could make it so that dm-migrations style migrations were generated instead of AR's.
- State changed from confirmed to hold
- Assigned user cleared.
- Milestone order changed from 0 to 0
Since I've got no experience using DM with rails-2.x and rails_datamapper, I'm unassigning myself from that ticket and put it on hold for now. If someone else still wants to take a stab, that's fine of course.