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
2 answers

Foreign keys and associations using DataMapper

I have read this page quite thoroughly: http://datamapper.org/docs/associations If the answer is on there, it's simply not expressed in a way I can understand. I'm very confused about using setting up relationship via Datamapper. The datamapper site…
hsiu
  • 271
  • 4
  • 11
1
vote
0 answers

Type error when using datamapper to query an Integer property

I have an issue with querying on Integer properties with datamapper. Datamapping configuration class Order include DataMapper::Resource storage_names[:default] = 'ORDER' property :order_id, Integer, :field => 'ORDER_ID', :key => true …
denBelg
  • 343
  • 1
  • 8
  • 20
1
vote
2 answers

DataMapper first_or_create always set certain field?

I'm using the following with datamapper to create/get a new user from my db: user = User.first_or_create({:id => data['id']}) This gets the user with id = data['id'] or creates it if it doesn't already exist. I want to know how to set other…
Fred
  • 1,021
  • 5
  • 13
  • 29
1
vote
1 answer

Datamapper do_postgres gem error: "dyld: lazy symbol binding failed: Symbol not found: _PQsetdbLogin"

I'm trying to run a Sinatra application with Datamapper and a Postgres db locally. I'm on Mac OS X 10.6.7 and ruby 1.9.2 and each time I launch the application, I get the following error: dyld: lazy symbol binding failed: Symbol not found:…
ms123
  • 581
  • 4
  • 12
1
vote
0 answers

How to switch from Sqlite to Postgres while installing Warden on Sinatra on Heroku

This is partly a problem-solving question, partly a "I'm trying to understand what's going on" question. I hope that's allowed. Basically, I'm trying to get Warden user authentication to work with Ruby/Sinatra and Postgres on Heroku. I got a lot of…
1
vote
1 answer

ruby data mapper, load and object and associated objects

How do I load an object and all associated objects? I'm asking because lazy loading (I think it's lazy loading) is causing me problems. Whilst this is a slow thing to do, it's fine as this script will only run once every 10mins. is there something…
Thermatix
  • 2,757
  • 21
  • 51
1
vote
1 answer

How to increment key values by power of two

I'm interested in storing multiple values in a single column, rather than use the traditional many-to-many table: class Beer include DataMapper::Resource property :id, Serial property :name, String property :containers, Integer # use bit…
craig
  • 25,664
  • 27
  • 119
  • 205
1
vote
0 answers

Having trouble accessing child from within Datamapper class

Trying to calculate the price of a hotel stay by the days stayed at the hotel. The problem is in the "def calculate price". The price is an attribute of the Space class which belongs to Booking. In my model I can call Booking.space.price, and bring…
1
vote
1 answer

Why can't I call self.save! inside of a Ruby DataMapper after :create callback?

I have the following minimal example DataMapper model: # model.rb require 'data_mapper' class Job include DataMapper::Resource after :create, :create_id_based_data property :id, Serial property :magicNumber, String def…
winni2k
  • 1,460
  • 16
  • 19
1
vote
0 answers

DataMapper Error with Models(`fetch': key not found: :precision (KeyError))

Really new to programming and the programming community, and this is only my second project programming with ruby so excuse me if I'm missing something obvious or doing something wrong. In this project so far, I'm trying to create a database using…
1
vote
1 answer

Datamapper equivalent of SQL Query

I have a Trees Class in my rails application. In there I have a field called 'leaves'. Now for a certain operation, I need to execute the following SQL command with a bitwise & operation under condition. SELECT * FROM trees WHERE (leaves & 6) =…
1
vote
1 answer

How to wrap Datamapper to_json response in a object-key hash

I'm working with a json parser that requires my response to be wrapped in an object-key hash. When I use DataMapper's .to_json method(datamapper/dm-serializer) the repsone I get is correct get '/plane/all' do @plane = Plane.all(:order =>…
PolitikP
  • 311
  • 3
  • 5
1
vote
1 answer

Getting a 404 on Ruby Sinatra App - Heroku

I have a simple Sinatra App. Works fine on local machine. Deployed it to Heroku and I keep getting a 404 on the logs. I promise I searched the web for around 5h straight and can't figure this out. The logs I get are: 2014-11-08T00:17:12.537150+00:00…
abarro
  • 25
  • 7
1
vote
0 answers

(ruby) How can I retrieve a list of hashes cascaded by parent_id?

I have in my database a table similar to this one: +----+--------+-----------------+ | id | parent | name | +----+--------+-----------------+ | 1 | 0 | father 1 | | 2 | 0 | father 2 | | 3 | 1 | child 1 - 3 …
1
vote
0 answers

Data mapper not saving object

require 'rubygems' require 'sinatra' require 'data_mapper' require 'dm-paperclip' require 'haml' require 'fileutils' require 'dm-migrations/adapters/dm-sqlite-adapter' require 'data_mapper' require 'dm-migrations' APP_ROOT =…
Joannah Nanjekye
  • 429
  • 1
  • 5
  • 16