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

Datamapper one-to-one association (has 1) issue

I am using datamapper in association with postgres I have 2 classes defined like this: class Dep include DataMapper::Resource property :id, Serial has 1, :rec, 'Rec' end class Rec include DataMapper::Resource property :id, Serial …
inertia
  • 404
  • 4
  • 15
1
vote
2 answers

Some data displayed as "not loaded" in rails console

I have a rails 3 application and I am fairly new to rails. I have an address model. When a form gets submitted, the address is saved successfully. In the address model, there is a field as follows: property :street_address, Text, :required =>…
arkiver
  • 465
  • 1
  • 5
  • 11
1
vote
0 answers

Using DB2 with JRuby Rails 3.2 DataMapper ORM

I recently became aware of DataMapper and see it's support for "legacy" database schemas is far superior to ActiveRecords'. This has inspired me to give it a go, however I've run into a snag trying to convert my existing working ActiveRecord…
1
vote
1 answer

Can a DataMapper scope use an associated model's scope?

Suppose I have a DataMapper scope for carnivores, like this: class Animal #... def self.carnivores all(:diet => 'meat') end #... end Can I reuse that scope in an association's scope? class Zoo #... def self.with_carnivores # Use…
Nathan Long
  • 122,748
  • 97
  • 336
  • 451
0
votes
1 answer

DataMapper datatype

Just want to know what are the corresponding datatype that I should declare when using DataMapper. Types in MySQL smallint bit varchar Can anyone tell me the corresponding type in DataMapper? Thanks.
revolver
  • 2,385
  • 5
  • 24
  • 40
0
votes
1 answer

Datamapper upgrade fails in rails 3.1 for 2nd repository

I'm trying to use Datamapper in my Rails 3.1 application and I'm having trouble mapping models that exist on a 2nd repository. I have the following class class Arp include DataMapper::Resource storage_names[:passive] = "arp" property :id,…
JoshReedSchramm
  • 2,751
  • 1
  • 27
  • 45
0
votes
1 answer

Simple association example for datamapper?

My code is below class City include DataMapper::Resource has n, :forums property :id, Serial property :name, String property :parent_state, String property :url, String, :length => 255 end class Category …
Tallboy
  • 12,847
  • 13
  • 82
  • 173
0
votes
2 answers

Boolean vs. Enum vs. Flag

I am working on a website that allows users to login. All users have 1 account, an account can have many orders. A user may be a client, worker, or manager. A client is never a worker nor a manager. a manager is also a worker. I would like to…
Don Wei
  • 431
  • 5
  • 16
0
votes
2 answers

Datamapper - Is id contained in result set

What's the most elegant way of knowing if the current selection ID is already part of the Datamapper results, without iterating through all of the results and building an Array? @saved_item = Array.new current_user.items.all.each do |item| …
Tom
  • 33,626
  • 31
  • 85
  • 109
0
votes
1 answer

DataObjects::DataError: Reader is not initialized, Rails 3 Ruby 1.9.2 MySQL Production

I seem to have a problem when attempting to run my Rails app on an Ubuntu server. It works perfectly on my development machine (Mac OS X Ruby 1.9.2 p180). I'm using DataMapper as my ORM which is causing the issues (in place of ActiveRecord). The…
0
votes
1 answer

Ruby 2.2.0 DataMapper: How to test numeric fields

I am working on Ruby 2.2.0, I have a class class JobOffer include DataMapper::Resource property :id, Serial property :title, String property :location, String property :experience, Numeric, :default => 0 property :description, String …
JohanaAnez
  • 31
  • 5
0
votes
0 answers

how do i save large amount of data into DB using DataMapper

Im trying to insert into the database but sinatra throws this error DataObjects::ConnectionError at / database is locked at line Name.create(babyname: name ,year1900: results[0] ,year1910: results[1] ,year1920: results[2] ,year1930:…
msc
  • 67
  • 8
0
votes
2 answers

Ruby Datamapper connection with SSL to MariaDB on Amazon RDS

How do I establish a ruby Datamapper connection to MariaDB on Amazon RDS with SSL? Here's what I did: A non-SSL connection works when testing with: uri = 'mysql://user:pass@host:port/db_name' connection = DataObjects::Connection.new(uri) =>…
stmllr
  • 652
  • 3
  • 18
0
votes
1 answer

Sorting elements in DataMapper

I have a database, and I need to sort the whole table by the length, however I've got stack on it. require 'dm-core' require 'dm-migrations' require 'sinatra/reloader' DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/development.db") class Item …
NLis
  • 53
  • 2
  • 8
0
votes
1 answer

How to make a Many-To-One relationship in DataMapper

I'm trying to create an association between two models: class Person include DataMapper::Resource property :id, Serial property :name, String end class Country include DataMapper::Resource property :id, Serial property :name,…