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
0
votes
1 answer

Ruby Datamapper will not insert serial data

I have created a Ruby script that gets serial data and if it starts with certain characters, prints string (SMS), inserts string into a file, parses string, then inserts parsed data into a MySql database. If I put a sample test string in place of…
0
votes
1 answer

DataMapper `has n` for different types of a model

I would like to have a model with different types of has n, for example: class Blog include DataMapper::Resource property :id, Serial has 1, :owner # of type user... has n, :authors # of type user... end class User include…
tekknolagi
  • 10,663
  • 24
  • 75
  • 119
0
votes
1 answer

Accessing the resource inside load/dump

consider the following example module DataMapper class Property class CustomType < DataMapper::Property::Text def load(value) # do stuff and return formatted value end end end end Class A property :name,…
Mudassir Ali
  • 7,913
  • 4
  • 32
  • 60
0
votes
1 answer

Ruby - DataMapper - Form - Create New - Format of HTML to populate DateTime object in Model class

Ruby hashes are great and Ruby with DataMapper is even greater... This is regarding instantiating a DateTime property in Ruby using Hashes. It is involved with DataMapper. I have a modal, User that has a birthday that is stored as DateTime class…
Ziyan Junaideen
  • 3,270
  • 7
  • 46
  • 71
0
votes
0 answers

In DataMapper, when using STI, what causes the error: undefined method 'key' for Object:Class

I'm getting a very strange error with DM 1.2 and a model that is sub-classed using single-table inheritance (STI): undefined method `key' for Object:Class That happens when I do a first query on the base model "User" (User.first) - however, queries…
mltsy
  • 6,598
  • 3
  • 38
  • 51
0
votes
1 answer

data_mapper find number of rows

I can't find an answer for this elsewhere, so I'm asking here: How do I "SELECT COUNT" with data_mapper? What I've tried: MyClass.count MyClass.size MyClass.all.count MyClass.all.size What does work is: ids = [] MyClass.all.each do |class| ids…
Alfo
  • 4,801
  • 9
  • 38
  • 51
0
votes
1 answer

Infinite recursion while overriding DataMapper methods

I'm trying to override the all() and first() methods in a DataMapper model I have, but there are some issues. My methods are being called, but (as became immediately obvious) they call themselves recursively and cause a SystemStackError. class…
AlexQueue
  • 6,353
  • 5
  • 35
  • 44
0
votes
1 answer

NoMethodError when defining custom DataMapper property type

I'm using DataMapper 1.2.0 and trying to define a custom property type to save in the database. I'm trying to understand how I'm supposed to do this, but I keep getting a NoMethodError. The object is a Dog, but this type comes from a gem I don't…
Stephen Jennings
  • 12,494
  • 5
  • 47
  • 66
0
votes
0 answers

rspec - why is "eql" matcher adding data to collection

I have two specs. They both test data from a common before(:all) block. If I run both, the second one fails. Putting in some logging statements, it seems like Week 1 is being added to @h_1 twice - but where is this happening? It seems to be…
JoeyC
  • 764
  • 11
  • 19
0
votes
1 answer

DataMapper::UpdateConflictError

Guys I hav below code snippet and I need remove an element from animals array, but I get UpdateConflictError zoo.animals # => Wolf,Tiger,Lion zoo.animals.delete("Wolf") # => Tiger, Lion zoo.update(:animals => zoo.animals) # =>…
tokhi
  • 21,044
  • 23
  • 95
  • 105
0
votes
1 answer

DataMapper - Set repository for many to many relationship using anonymous resource

I'm trying to migrate an old database using DataMapper and I am having an issue with a many to many relation. I have a Post and Tag model that both go through an anonymous resource. I can set the repository name in the post and tag models, but not…
Tom Brunoli
  • 3,436
  • 9
  • 36
  • 54
0
votes
1 answer

Ruby DataMapper One-to-Many association won't save using :parent_key

I have setup the following model with specific parent and child keys: class Province include DataMapper::Resource property :name_short, String, key: true, length: 2, unique: true property :name_long, String, length: 1..50 has n,…
Gus Shortz
  • 1,711
  • 1
  • 15
  • 24
0
votes
1 answer

How can I resolve the DataObjects::ConnectionError when running with data_mapper (Ruby 1.8.7)

When I run this code require 'rubygems' require 'data_mapper' require "sqlite3" DataMapper::setup(:default, "sqlite3://#{Dir.pwd}./prod.db") class Person include DataMapper::Resource property :id, Serial def initialize(name) self[:name]…
JoeyC
  • 764
  • 11
  • 19
0
votes
1 answer

DataMapper DB pool in Ruby App

I'm writing a multi-threaded Ruby application that is generating and loading data via dm-sweatshop into a legacy MySQL database for use in a load test. Everything is working fine with one exception, I'm loading several million records, but I can't…
jgnagy
  • 171
  • 2
0
votes
1 answer

Validating presence of 2 fields in DataMapper when an association does or does not exist

I have a model, User that has n, :accounts I want to validate the presence of 2 columns (email & passwd) in the User model when that instance does not have any associated accounts. The idea being that user that signs up with Facebook does not need…
nullfox
  • 597
  • 1
  • 4
  • 16