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

No Method Error on Sinatra

After setting up my config.ru and gemfile, my post no longer wants to work. First, I have to have my DataMapper.setup in my main.rb and I cannot run any DataMapper methods in my irb. Second, whenever I submit a form via POST for some data to be…
thank_you
  • 11,001
  • 19
  • 101
  • 185
0
votes
1 answer

How to: Single Table Inheritance in DataMapper?

I'm learning Sinatra (1.3.2) and chose to use DataMapper (1.2.0) as ORM and an in-memory SQLite (1.3.6) DB to start. Two models, Books and Downloads, are sharing most attributes, so I looked into declaring a model for STI (Single Table Inheritance)…
0
votes
2 answers

Freeze a property in DataMapper Model

Consider I have this following model definition, I want a particular property which should be constant from the moment it has been created class A property :a1, String, :freeze => true end Is there something like this? or may be using callbacks…
Mudassir Ali
  • 7,913
  • 4
  • 32
  • 60
0
votes
0 answers

Strange DataMapper Issue

I have a associative model, when I try to delete a record it returns true but the record still exists, The Model has 2 columns which are keys, while the third column is an enum, also a key.Any tips relating to updating/deleting a associative model…
Mudassir Ali
  • 7,913
  • 4
  • 32
  • 60
0
votes
1 answer

Ruby - Datamapper - Collecting records by joining two models

I have two tables users ------- id name organization_id organizations ---------- id org_name org_unique_num abc xyz organization_id in users table is foreign key to organizations table's id class Organization include DataMapper::Resource …
JVK
  • 3,782
  • 8
  • 43
  • 67
0
votes
1 answer

Query for the property from the associated table, computed values using DataMapper

Persons Table ------------------------------------------------------------ id | name | cost_price | sell_price | product_id | ------------------------------------------------------------ 1 person1 10000 20000 1 2…
Mudassir Ali
  • 7,913
  • 4
  • 32
  • 60
0
votes
1 answer

how to chop a DataMapper Collection into one Collection per day?

I have a DataMapper::Collection Object. Each of it's entries has a created_at property. I want to render the entries into html tables, one table per day (I use Sinatra for that). It was no problem to render everything into one table, but I didn't…
le_me
  • 3,089
  • 3
  • 26
  • 28
0
votes
1 answer

Datamapper: Create two relationships (has n and has 1) to the same model

I've got two models, that link to each other. class User include DataMapper::Resource property :id, Serial has n, :mail_addresses end class MailAddress include DataMapper::Resource property :id, Serial property :email, String,…
0
votes
2 answers

Ruby Datamapper model wrapped around a module prefix module name in the table name in sql query

I have a datamapper model as: module abc class Post include DataMapper::Resource property :title, String property :body, Text end end Note, my class is wrapped around module abc In other file I…
JVK
  • 3,782
  • 8
  • 43
  • 67
0
votes
1 answer

Attaching datamapper operator to ruby symbol and put into hash

I have: {xyz => [:abc, :klm, :nop]} I want to have something like this dynamically (22, 33, 44 are some random values): {:abc.gte => 22, :klm.gte => 33, :nop.gte => 44} gte is a Datamapper operator, as documented at…
JVK
  • 3,782
  • 8
  • 43
  • 67
0
votes
1 answer

Custom Ordering with NULL Values

I have a DataMapper class Song (through PostgreSQL) that has the following property: property :rating, Float, :required => false Users can rate songs. The problem is that I want users to browse available songs by rating. Say I have 5 songs, 3 of…
AlexQueue
  • 6,353
  • 5
  • 35
  • 44
0
votes
1 answer

Class method returning NoMethodError: undefined method Rails

I am writing a class method to find certain data in my database however I am getting a NoMethodError: undefined method error. I am using Datamapper instead of ActiveRecord. Here is my error output: NoMethodError: undefined method…
Hugs
  • 915
  • 4
  • 20
  • 47
0
votes
1 answer

Multiple many to one associations

In my app, each Game involves two players, who have different roles. One plays cat, the other plays dog. How can I describe this in Ruby's datamapper? The documentation only gives examples where the names of the properties match the name of the…
Colonel Panic
  • 132,665
  • 89
  • 401
  • 465
0
votes
1 answer

Find games involving player

In my models there is a many to many relation ship between games and users. How can I find all the games involving a given player? I tried Game.all(Game.users.include?(u)) but got a NoMethodError about include? Here are my models per…
Colonel Panic
  • 132,665
  • 89
  • 401
  • 465
0
votes
1 answer

Data-Mapper Under passenger and ruby 1.8

My sinatra app is showing an error when declaring required on fields using datamapper running on passenger and ruby 1.8 error: undefined local variable or method `required' for Person:Class class Person include DataMapper::Resource property :id,…
Will
  • 4,498
  • 2
  • 38
  • 65