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

Self-referential symmetric many-to-many

I'm quite stumped trying to model self-referential, many-to-many, symmetrical entity using Datamapper: I want to keep track of compatibility of various software releases I'm tracking: class SoftwareRelease include DataMapper::Resource …
Pawel
  • 1
  • 1
  • 2
0
votes
3 answers

Case Insensitive query in Datamapper

I am new to Datamapper. Is there any way to write case insensitive query in datamapper because I am searching for presence of a name in a table with datamapper. Normally we write query in datamapper like this say, Student.all(:name => "XYZ") where…
Joy
  • 4,197
  • 14
  • 61
  • 131
0
votes
1 answer

Datamapper: count favs

I am working on a Sinatra image app. I have defined Datamapper models for my users, the uploaded images, and "Favs". Each user can give a maximum of one "Fav" to each image. class User include DataMapper::Resource property :id, Serial property…
tobias.henn
  • 225
  • 2
  • 13
0
votes
0 answers

Install dm-postgres-adapter on Mac

I've been fighting on this for two days, time to ask to StackOverflow. I've prepared a simple Ruby app (noob alert!) to start with this language. I've used Sinatra and DataMapper. When using MySql everything went fine. I've installed the…
Enrichman
  • 11,157
  • 11
  • 67
  • 101
0
votes
1 answer

DataMapper many-to-many association

At the moment I have the database model up and can populate the models with data: user.persons << person group.functions << function group.classificationlevels << clasfication user.groups << group These are the models I am using at…
Steven Bakker
  • 435
  • 1
  • 3
  • 12
0
votes
1 answer

NoMethodError for 'update' in Ruby

I've been having trouble for a while getting this put method to work. I'm getting the following error message on the 'success' line: NoMethodError - undefined method `update!' for nil:NilClass Please see the code below: #edit download put…
Phil Hudson
  • 3,819
  • 8
  • 35
  • 59
0
votes
1 answer

How do I export data from CSV to DataMapper in Sinatra?

I'm building a simple web application using Sinatra. I have an external text file and would like to parse it using CSV. Then I would like to export the data and create a database using DataMapper. I'm stuck on how to accomplish this. This is what I…
GabeLafontant
  • 63
  • 1
  • 4
0
votes
1 answer

Group DataMapper records, then sort within those groups

I have records that I'd like to sort like this: Status Date Frank STATUS_A Jan 1, 2013 Jenny STATUS_A Feb 2, 2013 Alice STATUS_A Mar 3, 2013 Bob STATUS_B Jan 1, 2013 Zeke STATUS_B Feb 12, 2013 Harry STATUS_B …
Daniel May
  • 2,192
  • 5
  • 25
  • 43
0
votes
1 answer

Dynamic queries with DataMapper

I would like to be able to make dynamic queries with DataMapper ,for searching an Sqlite database for my Sinatra project.Is it possible? So far I have come up with something like this trying to get the songs that are sang from the artist specified…
magmike
  • 473
  • 1
  • 5
  • 18
0
votes
1 answer

404 Error in Sinatra App using DataMapper

I am trying to extend an example I saw in a sinatra book.I wanted to experiment with DataMapper so I ended up with this: require 'dm-core' require 'dm-migrations' require 'rubygems' require 'sinatra' configure:development do …
magmike
  • 473
  • 1
  • 5
  • 18
0
votes
1 answer

Datamapper [ruby] on Legacy Schemas

I'm working with a legacy schema which has 3 particular tables backing a single class, listed below: table_1_month # All items that are < 1 month old. table_1_year # All items that are between 1 month and 1 year old. table # All items that are…
0
votes
1 answer

How to overwrite Ruby DataMapper's create and first_or_create method?

I could overwrite DataMapper's save, delete, destroy! method using module, such as: require 'data_mapper' module Record def self.included(base) base.class_eval do include DataMapper::Resource property :id,…
Kokizzu
  • 24,974
  • 37
  • 137
  • 233
0
votes
1 answer

datamapper - query over an object property

using datamapper with ruby. Suppose i have a model called Post: class Post include DataMapper::Resource property :id, Serial property :name, String, length: 255 property :category_ids, Object end Post.create(name: 'My post', category_ids:…
Marcus Mansur
  • 337
  • 1
  • 4
  • 14
0
votes
2 answers

DataMapper: Fetching only changed properties before updating record

Hoping someone can point me in the right direction with this. I want to know if there's a way to view/fetch both new and old property values with DataMapper before the update method is called and compare the values. The scenario is as follows: I…
ghstcode
  • 2,902
  • 1
  • 20
  • 30
0
votes
1 answer

DataMapper's many-to-many get all foreign IDs

NEW QUESTION: easier test case, create a database CREATE USER test WITH PASSWORD $$test$$; CREATE DATABASE test; GRANT ALL PRIVILEGES ON DATABASE test TO test; # add to pg_hba.conf if needed datamapper setup: require…
Kokizzu
  • 24,974
  • 37
  • 137
  • 233