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

Add to the end of datamapper json

I was wondering how to add another key value pair to the end of the JSON generated by DataMappers .to_json method. When I try to call to_json(:methods => [:total_pages]), it ignores the methods bit all together. I would like it to produce something…
Tom Brunoli
  • 3,189
  • 9
  • 33
  • 52
0
votes
2 answers

Ruby: How to get array instead of DataMapper::Collection in query result

here is my code: today_ids_from_db = Rating.all(:fields => 'my_id', :ts_d => Time.now) today_ids_from_db.class == DataMapper::Collection but I need to get simple ruby array with my_id values how to achieve this?
user973254
  • 2,728
  • 2
  • 15
  • 19
0
votes
1 answer

DataMapper: Set default validations on custom types

I just wrote a custom DM type to help me with this thing. Inherits from String, and all that jazz. Just now I'd like to have a default validation. So, something that I as a user don't need to define, it is just implicitly there. For instance, for an…
ChuckE
  • 5,040
  • 2
  • 27
  • 54
0
votes
1 answer

How to reload instances using DataMapper

I'm using DataMapper as ORM framework after many years of experience with AR. For that reason I sometimes try to find a specific DM function that mirrors some behaviour from AR. Sometimes I'm lucky, sometimes I'm not. With the #reload directive, I'm…
ChuckE
  • 5,040
  • 2
  • 27
  • 54
0
votes
2 answers

Specify table name mid application Ruby-Datamapper

I'm wanting to dynamically create and query tables using Datamapper. While Datamapper allows you to work with legacy tables and schemas, and in this way set the table name used this is only during initialisation, not within the application. Is there…
djlumley
  • 2,791
  • 2
  • 22
  • 30
0
votes
1 answer

How to associate these three models to get the appropriate output?

I am just starting out with Ruby. I am making a little app in Sinatra and I am using Datamapper with a sqlite3 db. Below are the three models I have that I am creating. class Team include DataMapper::Resource property :id, Serial property…
0
votes
1 answer

DataMapper.get(:attribute => value) returning nil

Model: class Country include DataMapper::Resource property :id, Serial property :name, String property :continent, String end I'm trying to do a query by the name attribute: Country.find(:name => "value") But it keeps returning me a nil.…
tommi
  • 6,714
  • 8
  • 35
  • 58
0
votes
1 answer

ruby Datamapper is not inserting all records

I have this ruby function which yields 1095 records MusicTab::FOps.gen_list('/fun/Music') and I want to store them using datamapper. When I do this MusicTab::FOps.gen_list('/fun/Music') do |arr_f| @files=Files.create( :file_path => arr_f[0], :title…
pahnin
  • 4,631
  • 11
  • 34
  • 56
0
votes
1 answer

DataMapper conection on Heroku using development database not ENV['DATABASE_URL']?

My issue is that when deployed to Heroku DataMapper tries to use this part of my database connection info 'postgres://postgres:myohmysosecret@localhost/recall' when I have DataMapper.setup(:default, ENV['DATABASE_URL'] ||…
camelCaseD
  • 1,997
  • 4
  • 25
  • 42
0
votes
2 answers

Advanced DataMapper search for Many to Many relation

Give the Tag/Photo exemple on DataMapper documentation: class Photo include DataMapper::Resource property :id, Serial has n, :taggings has n, :tags, :through => :taggings end class Tag include DataMapper::Resource property…
cpereira
  • 155
  • 9
0
votes
1 answer

How to destroy an many-to-many object and its link in DataMapper/Sinatra/Ruby

I am a newbie and would appreciate some help on how to resolve this problem. I have tried to follow the documentation in DataMapper and have not found any solutions via Google on how to destroy an object and its corresponding links. Here are the…
0
votes
1 answer

Error installing datamapper gem on lion

I am trying to install the datamapper gem on mac os x lion but am getting failed to build gem native extension while installing the sqlite adapter (see terminal output below). The two solutions I found from google and other stack overflow questions…
Ben
  • 557
  • 2
  • 10
  • 23
0
votes
2 answers

Sinatra route returning enumerator instead of json object

I am trying to do the following in a sinatra route: get '/posts/:id' do Post.find(params[:id]).to_json end But this is returning an enumerator. How do I access a single object in json format? PS I'm using datamapper EDIT I managed to return the…
Darcbar
  • 888
  • 1
  • 8
  • 25
0
votes
1 answer

Datamapper type for char (aka character) field type

I'm working with an open source database. I'm trying to map it to classes with DataMapper, and later I'm going to make changes in a Model driven approximation instead of a Database driven one. But first I would like to map the open source database…
Waiting for Dev...
  • 11,486
  • 5
  • 41
  • 56
0
votes
2 answers

merb cannot load dm-mysql-adapter

Would you help me on this issue? gem list shows that dm-mysql-adapter has been installed, but merb cannot load it. I just want to start a simple merb application generated by merb-gen. Loading init file from ./config/init.rb Loading…
Hardbone
  • 327
  • 1
  • 3
  • 16
1 2 3
16
17