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

Select unique records without natural keys

For example, I have table names: id integer primary key, name text unique and unique index for names(name). I want to select records by index-style syntax: (n12, nBill) = (Name[12], Name['Bill']) or with Name.get['Smitt']. As documentation says, it…
emett
  • 128
  • 13
1
vote
1 answer

Can I check the validity of a single DataMapper property?

In a custom DataMapper setter, I'd like to check whether the value I'm setting is valid or not. For instance: class ToastMitten include DataMapper::Resource property :id, Serial property :wearer, Enum['Chuck Norris', 'Jon Skeet'] property…
Nathan Long
  • 122,748
  • 97
  • 336
  • 451
1
vote
2 answers

Data mapper not working (uninitialized constant)

I'm playing around with Sinatra and following a simple tutorial I found online ( http://carlosgabaldon.com/articles/singing-with-sinatra/). The thing is though, every time I try to enter DataMapper::Database.setup({... I get uninitialized constant…
Keva161
  • 2,623
  • 9
  • 44
  • 68
1
vote
1 answer

Datamapper object nil on redirect, refresh always loads fine

I'm developing a Rails app that does some plotting behind the scenes to generate a Comparison between various datasets. What I'm seeing is a sporadic 500 error (ActionView::Template::Error) on generation of the Comparison object in my DataMapper…
Ryanmt
  • 3,215
  • 3
  • 22
  • 23
1
vote
1 answer

Destroying "has n, :things, :through => Resource" associations in DataMapper

I have a collection class called MySet: class MySet include DataMapper::Resource property :id, Serial has n, :my_elements, :through => Resource def add integer unless my_elements.first(:integer => integer) my_element =…
Martin Harrigan
  • 1,044
  • 11
  • 28
1
vote
2 answers

Setting up dm-rails with Rails 3.2?

How can I get dm-rails to play well with the rest of the Rails 3.2 stack?
Larsenal
  • 49,878
  • 43
  • 152
  • 220
1
vote
1 answer

How to properly access a belongs_to model's properties

Using the following classes and their associations. class Repository include DataMapper::Resource property :id, Serial property :name, String has n, :branches end class Branch include DataMapper::Resource property :id, Serial property…
Kevin Jalbert
  • 3,115
  • 3
  • 26
  • 39
1
vote
1 answer

How difficult is it to switch from ActiveRecord to DataMapper in Rails 3.1?

I'm starting a new project and I have maybe three resources defined. Not a lot of code so far. (Rails 3.1) But I'm interested in trying out DataMapper. I'm used to ActiveRecord (and actually enjoy it) but I'm always on the lookout for new things.…
cbmeeks
  • 11,248
  • 22
  • 85
  • 136
1
vote
1 answer

New Rails 3.1.3 + Datamapper routing assets issue

I am eager to try out DataMapper for a new Rails project. I created my project using the following command: rails new project_name -m http://datamapper.org/templates/rails.rb I decided to test out my application by running: rails server When I go…
Silverbolt
  • 7,093
  • 5
  • 20
  • 18
1
vote
2 answers

Ruby in Sinatra using DataMapper not retrieving associations

For some reason my model does not contain the associated models I linked using has n. My definition is as follows: class Post include DataMapper::Resource has n, :comments property :id, Serial property :name, String end class…
tomvo
  • 1,409
  • 1
  • 12
  • 21
1
vote
2 answers

Is Datamapper's dm_mysql_adapter gem supported on windows?

I am wanting to play some more with Ruby and currently seem to have a grasp of sinatra, but would also like to now pull in data from a relational database. I tend to use Mysql for test apps and tried installing the gems but I keep getting an…
Grofit
  • 17,693
  • 24
  • 96
  • 176
1
vote
1 answer

Sessions with DataMapper don't work due to an ArgumentError

I have the following in session_store.rb. I'm running Ruby 1.8.7 and rails 3.1.0.rc4 require 'dm-rails/session_store' ActionDispatch::Session::DataMapperStore = Rails::DataMapper::SessionStore Contendable::Application.config.session_store…
1
vote
1 answer

How can I get Sinatra to return a record matching today's date?

My Sinatra app is a collection of notes. Each note is assigned a (future) date when it should be published: class Note include DataMapper::Resource property :id, Serial property :publish_date, Date property :content, String …
rda3000
  • 1,410
  • 1
  • 18
  • 31
1
vote
0 answers

Ruby mysql mysql2 AND datamapper how to reconnect

I have something running constantly doing periodic queries. I have used both DataMapper (though I'm doing raw SQL through it) and mysql2. Using either, occasionally they stop working. I believe it's because the server hiccuped or…
Hsiu Dai
  • 1,303
  • 2
  • 14
  • 21
1
vote
2 answers

DataMapper associations/validation causing save failure

So I'm having some trouble with DataMapper and object associations. (Code provided at bottom). I'm getting errors upon saving to the extent that some id's are not set, which I think has something to do with how I setup my associations/not fully…
axiixc
  • 1,962
  • 18
  • 25