Questions tagged [ruby-datamapper]

DataMapper is a Object Relational Mapper written in Ruby. It implements an architectural pattern with the same name (with some changes).

Key features of Datamapper:

  • query chaining (delaying actual talking to a DB until necessary)
  • bulk loading of several data rows with one query
  • very abstract design allowing non-SQL adapters
  • lazy loading of large fields

Home page http://datamapper.org/

242 questions
1
vote
1 answer

DataMapper- can I avoid intermediate tables?

I am a total beginner at DataMapper, and have two models: class ThirdPartyAccount include DataMapper::Resource property :access_token, String, :length => 500 belongs_to :user end class User include DataMapper::Resource …
Alastair
  • 5,894
  • 7
  • 34
  • 61
1
vote
1 answer

Creating new Datamapper resources (database entries) using .each

I want to take Google Custom Search API results and add them to a database using Datamapper. I've managed to successfully set up and manually add some items to the database, so it seems like that is all set up correctly. I'm using HTTParty to make…
elgonquin
  • 67
  • 6
1
vote
1 answer

DataMapper does not see a property assigned with @

I'm getting started with Ruby and DataMapper and I stumbled upon a problem which I think does not make any sense. Let's say I have the following model : class Foo include DataMapper::Resource property :id, Serial property :date, Date,…
marco-fiset
  • 1,933
  • 1
  • 19
  • 31
1
vote
1 answer

Ruby DataMapper: model associations review, model updates after finalize, and associating slightly autonomous records

I am brand new to Ruby and even newer to DataMapper, or any ORM for that matter. I come from a Perl background and am not really an OOP type of developer. So I'm wandering in unknown territory here. Apologies for the long-winded question... In this…
Jim
  • 1,499
  • 1
  • 24
  • 43
1
vote
1 answer

can I join two join resources together?

The way I have implemented it, it would appear not. In data_mapper terms - I have a join resource Entry, that joins Driver, Team and Season I have a join resource Race that joins Track and Season I have a join resource Placing that joins Entry and…
JoeyC
  • 764
  • 11
  • 19
1
vote
4 answers

How to make Ruby hash of arrays from array

I'm a Perl developer trying to learn Ruby... So, I'll demonstrate in Perl what I'm trying to accomplish in Ruby and then summarize at the end... #!/usr/bin/perl -w use strict; use Data::Dumper; # Given the following data structure (an array of…
Jim
  • 1,499
  • 1
  • 24
  • 43
1
vote
1 answer

Paginating DataMapper

I have a pretty basic model called Review (basically just an ID serial and some text columns) and I'm making a simple pagination system for it. The following code: Review.all(:limit => per_page, :offset => offset, :order => [ :id.asc ]) Returns…
AlexQueue
  • 6,353
  • 5
  • 35
  • 44
1
vote
1 answer

(Mongodb & Datamapper) uninitialized constant DataMapper (NameError)

I try to use datamapper and mongoid on my project. I followed the link https://github.com/solnic/dm-mongo-adapter. But there is no so much information. I assimilate to datamapper and sqlite3 adapter in this post:…
pegatron
  • 516
  • 4
  • 16
1
vote
1 answer

stack overflow in datamapper from has n relationship

In my Profile class the has n association with :fields is problematic. If it's there and I run the following: user = User.create user.profiles << Profiles.new user.save Profile.all The following exception is thrown: SystemStackError: stack level…
Jon
  • 462
  • 4
  • 13
1
vote
1 answer

DataMapper enum field doesn't persist when saved or updated

I am trying to map a legacy MySQL database with a fresh DataMapper model. MySQL schema: CREATE TABLE IF NOT EXISTS `backer` ( `backer_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `secret` varchar(16) NOT NULL, `email` varchar(255) DEFAULT…
Daniel May
  • 2,192
  • 5
  • 25
  • 43
1
vote
2 answers

How do I get all different property values of a ruby DataMapper::Collection?

I'm using ruby 1.9.3 and ruby-datamapper with postgresql. I have got a table full of entries, each of them has three properties: id ,text and created_at. The last one is a Date object. In my application I SELECT some entries like so: collection =…
le_me
  • 3,089
  • 3
  • 26
  • 28
1
vote
1 answer

DataMapper Error in Sinatra - NameError: Cannot find the child_model

Using Sinatra and DataMapper. This is my first time trying to use more than two model classes. Not sure what is causing the error. Thanks. The error: NameError: Cannot find the child_model ContactNote for Contact in contact_notes The models: class…
Erik D
  • 47
  • 1
  • 6
1
vote
1 answer

In Ruby/Sinatra, Datamapper's .all works but .get doesn't?

I am trying to take data from a path in Sinatra, and use it to look up a particular record using Datamapper. The Datamapper docs seem to indicate that. get "/test/:test_path" do test_get = Intake.get( params[:test_path] ) # Do stuff erb…
Clay Shirky
  • 123
  • 9
1
vote
1 answer

Unable to destroy a parent object

I have a large and complicated User model that looks something like this: class User class Link include DataMapper::Resource property :id, Serial, :key => false belongs_to :follower, :model => 'User', :key => true belongs_to…
AlexQueue
  • 6,353
  • 5
  • 35
  • 44
1
vote
1 answer

Datamapper - before :destroy callback being called twice?

For some reason, when I call destroy on an instance of one of my DataMapper models, the "before :destroy" callback is being executed twice, leading to errors. The model in question has a belongs_to association with another model, which has a…
Richard Stokes
  • 3,532
  • 7
  • 41
  • 57