Questions tagged [datamapper]

Architectural pattern for separating application logic from storage.

Objects and relational databases have different mechanisms for structuring data.

The Data Mapper is a layer of software that separates the in-memory objects from the database. Its responsibility is to transfer data between the two and also to isolate them from each other. With Data Mapper the in-memory objects needn't know even that there's a database present; they need no SQL interface code, and certainly no knowledge of the database schema.

Pattern definition: http://martinfowler.com/eaaCatalog/dataMapper.html

1130 questions
6
votes
1 answer

Datamapper validations, empty errors

I have a simple model with the following properties: property :title, String, :required => true, :length => 1..200 property :body, String, :required => true, :length => 1..200 When I save it (using the save method) with an title that…
ms123
  • 561
  • 4
  • 12
6
votes
2 answers

What, *specifically*, makes DataMapper more flexible than ActiveRecord?

I'm comparing Doctrine 2 and Propel 1.5/1.6, and I'm looking in to some of the patterns they use. Doctrine uses the DataMapper pattern, while Propel uses the ActiveRecord pattern. While I can see that DataMapper is considerably more complicated, I'd…
Billy ONeal
  • 97,781
  • 45
  • 291
  • 525
6
votes
1 answer

Error when installing dm-mysql-adapter

I am very new to Ruby . I installed DataMapper and I am trying to install dm-mysql-adapter-1.0.2 gem . But when I try to install , I get the below error . I am using ubuntu OS . vinoth@vinoth-laptop:~/Downloads$ gem install dm-mysql-adapter-1.0.2 --…
Vinoth Kumar C M
  • 9,668
  • 27
  • 81
  • 125
6
votes
1 answer

Migrate existing ROR app to GAE

I have managed to run a basic rails app1 on App Engine using: http://gist.github.com/268192 So, on my basic app2, I install CE, which works fine on local machine. (communityengine.org) But, when I follow the same steps on my actual app2,…
zengr
  • 36,384
  • 37
  • 121
  • 187
6
votes
4 answers

Data Mapper pattern, exceptions, and handling user-provided data

In applying the Data Mapper pattern, the model (Domain Model in my case) is responsible for business logic where possible, rather than the mapper that saves the entity to the database. Does it seem reasonable to build a separate business logic…
eoinoc
  • 2,725
  • 3
  • 22
  • 37
6
votes
3 answers

why is before :save callback hook not getting called from FactoryGirl.create()?

This simple example uses DataMapper's before :save callback (aka hook) to increment callback_count. callback_count is initialized to 0 and should be set to 1 by the callback. This callback is invoked when the TestObject is created…
fearless_fool
  • 29,889
  • 20
  • 114
  • 193
6
votes
1 answer

error happens when I try "all" method in datamapper

When I try to do this in Sinatra, class Comment include DataMapper::Resource property :id, Serial property :body, Text property :created_at, DateTime end get '/show' do comment = Comment.all @comment.each do…
toniowhola
  • 81
  • 1
  • 5
5
votes
2 answers

How to get datamapper to work with a postgresql database?

I have found several examples using datamapper and was able to get them to work. All these examples are for a sqlite database though. I'm trying to use datamapper with postgresql. I changed the call in datamapper from sqlite3 to postgres, and I've…
node ninja
  • 28,340
  • 55
  • 153
  • 242
5
votes
1 answer

Adjustments needed in a Rails app to use Datamapper instead of ActiveRecord

I am trying to use Datamapper in a Rails app as an alternative to ActiveRecord. I've followed the various setup instructions and have Datamapper working in my app. But one of the first things I noticed that no longer works is this: <%=…
Baker
  • 53
  • 5
5
votes
1 answer

Separate Sinatra app's test database from development database?

As a learning exercise, I am building a practice app using Sinatra, Datamapper and RSpec. I am using this template, which is basically a boilerplate for all the above. The problem I am having is that the way RSpec and Datamapper seem to be…
Jeff K.
  • 152
  • 1
  • 5
5
votes
2 answers

Sinatra + Heroku + Datamapper deploy issues with dm-sqlite-adapter

For some reason, heroku tries to require dm-sqlite-adapter, even though it should use Postgres here. Note, that this happens when I open any URL - not during the git push itself. I built a default facebook app. The Gemfile: source :gemcutter gem…
LordTwaroog
  • 1,728
  • 12
  • 22
5
votes
3 answers

Installing dm-types on Windows. (Win7 x64)

I am trying to install dm-types for DataMapper on my machine with gem install dm-types I've installed Ruby from RubyInstaller (1.9.3) and I also have the DevKit installed. (Aswell as some other gems like sinatra, haml, dm-core and…
Lev Dubinets
  • 766
  • 9
  • 29
5
votes
3 answers

Setting up Associations with DataMapper & Sinatra

Ok, so this is driving me crazy. I have read the Associations article and example and been trying to work this out for the las three days and I'm tired of this making me feel dumb, so... How does one set up associations with DataMapper? (I am…
Don Graziano
  • 431
  • 5
  • 15
5
votes
2 answers

No Such Table error from SQLite memory DB via DataMapper

I have a Ruby program that uses DataMapper as an ORM to talk to an in-memory SQLite DB. This has been working fine, however I just recently added a new DM class, and corresponding table. To my surprise, things now blow up during an…
Aaron
  • 53
  • 1
  • 3
5
votes
1 answer

Using a Pagerfanta/ non ArrayAccess list in a bulk form

I'm adding checkboxes for bulk actions to a CRUD list, using the solution provided here. However, my results are paged with Pagerfanta, so it seems I need to use a DataMapper in my form. I have tried various solutions, but cannot get the selected…
jdog
  • 2,309
  • 5
  • 34
  • 65