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 chaining conditions seem to be sharing conditions

I have two models; class Foo belongs_to :bar end class Bar has 1, :foo end This all works fine, relationship working fine and so on. The requirement arose for us to override the "all" method on Foo, to always put a condition into any query. We…
Mikey Hogarth
  • 4,672
  • 7
  • 28
  • 44
1
vote
2 answers

Can't upload image to Cloudinary from Sinatra

I'm trying to upload an image to Cloudinary from within my Sinatra web app. I got it saving the image locally by using CarrierWave and I know Cloudinary and CarrierWave play nicely with each other but I've tried everything and no dice. I've followed…
Jem
  • 306
  • 1
  • 13
1
vote
2 answers

DataMapper: Sorting results by association count (number of related objects)

Given are movies and actors in an m:n relation. What I want to do is retrieve a list of actors, ordered by the number of movies they played in. class Movie include DataMapper::Resource property :id, Serial property :title, String has n,…
rbq
  • 136
  • 4
1
vote
0 answers

Datamapper: renaming a has n relationship key

I am trying to create a set of models to express Posts and Users where Users author posts and can also Like posts. The following code seems to produce the right set of SQL tables, however the last lookup fails because of conflict in User :posts key…
Alo Sarv
  • 376
  • 3
  • 4
1
vote
1 answer

Slow Ruby DataMapper.setup

I found that my Sinatra application was so freaking slow, only happens on VMWare image on i3, i don't know why, it doesn't happened on same VMWare image on AMD APU, the line that causes the slowness is: DataMapper.setup(:default,…
Kokizzu
  • 24,974
  • 37
  • 137
  • 233
1
vote
1 answer

Foreign reference in data mapper

Say I have two data mapper classes like this: class Family include DataMapper::Resource property :id, Serial property :nice, Boolean end Class Person include DataMapper::Resource property :id, Serial belongs_to…
Matthew Sainsbury
  • 1,470
  • 3
  • 18
  • 42
1
vote
1 answer

Updating Object property in DataMapper

Using DataMapper, I have noticed that unless I modify the entire Object, the property is not updated - updating fields of an object and then saving does not persist changes. I'm updating the value attribute of my UnitValue class, which I store as an…
Aram Kocharyan
  • 20,165
  • 11
  • 81
  • 96
1
vote
0 answers

Datamapper - create unique index over belongs_to attribute

I'm using DataMapper connected to an SQLite backend. I need to create a Unique index across my four belongs_to columns. Here is the table. class Score include DataMapper::Resource property :id, Serial property :score, Integer belongs_to…
Daryll Santos
  • 2,031
  • 3
  • 22
  • 40
1
vote
1 answer

Using DataBase Cleaner gem with DataMapper

I am writing a test using RSpec and FactoryGirl. In my models DataMappers have been used. Here in RSpec I am testing two methods update and index function of my controller where I am using two objects A, B and C. I have created them by using…
Joy
  • 4,197
  • 14
  • 61
  • 131
1
vote
1 answer

Data is not deleted properly after running of Spec

In my RSpec file, I have used FactoryGirl to create objects that I have used in my RSpec file. In my RSpec file I have used three objects A, B and C where C is dependent on B and B is dependent on A. Here in RSpec file I have written two test…
Joy
  • 4,197
  • 14
  • 61
  • 131
1
vote
1 answer

Create JSON from 2 associated Datamapper models

Here is my question. I have 2 associated Datamapper models: class Task include DataMapper::Resource property :id, Serial property :date, Date property :amount, Float belongs_to :project, :required => true end class…
user1312365
1
vote
1 answer

LoadError on Windows when trying to generate a model

When trying to generate a model in a new Padrino project, I get the following: C:\temp\ruby\test>padrino g model client C:/Ruby193/lib/ruby/gems/1.9.1/gems/do_sqlite3-0.10.13-x86-mingw32/lib/do_sqlite 3.rb:32:in `require': 126: The specified module…
mydoghasworms
  • 18,233
  • 11
  • 61
  • 95
1
vote
0 answers

ruby datamapper breakdown of Serial vs String property for key

Should every table have a Serial id? When would you need one, when wouldnt you? (associations, performance, etc?) YouTube identifies videos with a key like "ttpYdIodMWc". I want something similar, but can't decide between id and identifier, or just…
AJcodez
  • 31,780
  • 20
  • 84
  • 118
1
vote
1 answer

Sharing attributes between models - Datamapper

I have two models that share some of the same attributes so I wanted to setup a single table inheritance structure. After doing some research, I found out that I can use module to achieve the same by doing the following instead: module…
pwc
  • 161
  • 1
  • 10
1
vote
1 answer

ruby datamapper - symmetric self-referential many-to-many relationship

I'm not an expert in databases and relational logic and I'm a bit confused about what I have to do in the following situation. I have a model Expression where I want to implement a TranslationPair self referencing many to many relationship. class…
Waiting for Dev...
  • 12,629
  • 5
  • 47
  • 57