Questions tagged [datamapper]

Architectural pattern for separating application logic from storage.

Objects and relational databases have different mechanisms for structuring data.

The Data Mapper is a layer of software that separates the in-memory objects from the database. Its responsibility is to transfer data between the two and also to isolate them from each other. With Data Mapper the in-memory objects needn't know even that there's a database present; they need no SQL interface code, and certainly no knowledge of the database schema.

Pattern definition: http://martinfowler.com/eaaCatalog/dataMapper.html

1134 questions
0
votes
1 answer

Class method returning NoMethodError: undefined method Rails

I am writing a class method to find certain data in my database however I am getting a NoMethodError: undefined method error. I am using Datamapper instead of ActiveRecord. Here is my error output: NoMethodError: undefined method…
Hugs
  • 915
  • 4
  • 20
  • 47
0
votes
1 answer

Accessing parent method in ruby to write a wrapper of that method

class Package include DataMapper::Resource property :id, Serial property :product, String, :required => true def self.create(attributes = {}) puts 'I am in the Object method' #do something here with value of product…
JVK
  • 3,782
  • 8
  • 43
  • 67
0
votes
2 answers

Single interface implementing both Data Mapper and Repository - any benefits?

Data Mapper is a layer of Mappers that moves data between objects and a database while keeping them independent of each other and the mapper itself. Repository mediates between the domain and data mapping layers using a collection-like…
user702769
  • 2,435
  • 2
  • 25
  • 34
0
votes
1 answer

Multiple many to one associations

In my app, each Game involves two players, who have different roles. One plays cat, the other plays dog. How can I describe this in Ruby's datamapper? The documentation only gives examples where the names of the properties match the name of the…
Colonel Panic
  • 132,665
  • 89
  • 401
  • 465
0
votes
1 answer

Find games involving player

In my models there is a many to many relation ship between games and users. How can I find all the games involving a given player? I tried Game.all(Game.users.include?(u)) but got a NoMethodError about include? Here are my models per…
Colonel Panic
  • 132,665
  • 89
  • 401
  • 465
0
votes
1 answer

Fetching mysql error from datamapper

Is there anyway to fetch the mysql error in datamapper (I am using Sinatra) @params = {"product"=>"client", "os"=>"windows", "architecture"=>"32", "version"=>""} @a = Package.new(@params) @a.save @a.save returns me false, because version cannot be…
JVK
  • 3,782
  • 8
  • 43
  • 67
0
votes
1 answer

"schema_migrations" table for data mapper migrations

I am using datamapper instead of activerecord for my Rails App. I want to see the version details, but I can't see the schema_migrations table any where. What should I do?
Sayuj
  • 7,464
  • 13
  • 59
  • 76
0
votes
2 answers

using a regex with datamapper

is it possible to use a regular expression with the DataMapper ".like" conditional syntax? for example, i would like to find only those users whose hobby starts with the string "skating". the regex would look something like…
SeanPlusPlus
  • 8,663
  • 18
  • 59
  • 84
0
votes
1 answer

Is there a better way to store one incremented Integer in a db in a thread safe way than blocking?

I'm developing a Sinatra app which uses unicorn. Each worker is one thread, it loads the whole application, they just share the db. (please correct my if I'm wrong ;) ) The first thread gets the Integer, does something with it and then increments…
le_me
  • 3,089
  • 3
  • 26
  • 28
0
votes
1 answer

Datamapper: Deleting all records that have no relations

How would I go about deleting all records from a table that have no relation in datamapper? The tables in question are a Post and Tag table (in a many-to-many relationship) and I would like to delete all Posts that have no tags. For some reason when…
Tom Brunoli
  • 3,436
  • 9
  • 36
  • 54
0
votes
0 answers

efficient way to make unique set from datamapper query

I am am using DataMapper and Sinatra and I am trying to create a unique set of elements from a DataMapper entity property. I search the database for a collection of entries. These entries all have a "category" property. I would like to find an…
Jon Rose
  • 1,457
  • 1
  • 15
  • 25
0
votes
1 answer

Rails 3 Nested Forms with datamapper

i have two models: class MeetingPoint include DataMapper::Resource belongs_to :profile property :id, Serial property :lat, String end and class Profile include DataMapper::Resource has n, :meeting_points property…
0
votes
1 answer

Ruby Datamapper .count always returns 0

Whenever I try and count the returned records from datamapper it always returns as 0, whether there is a user or not. User.count(:username=>params[:username]) class User include DataMapper::Resource property :id, Serial property :username, …
DCWill
  • 3
  • 2
0
votes
1 answer

Datamapper not accepting regex

I'm using a regex to validate a form field in my sinatra app that's being sent to my db using the data_mapper gem. The code I'm using for the field in my model is: property :price, Float, :required => true, :format => /\$?\d{0,3}\.{1}\d{2}/ And…
Stuart Nelson
  • 4,202
  • 2
  • 23
  • 26
0
votes
1 answer

How to use Code first Fluent API for inheritant data structure?

I have a code first application which defined like this: public abstract class Entity { [Key] public int Id { get; set; } public DateTime CreatedOn { get; set; } } public class Post : Entity { public string Text { get; set; } …
Delta76
  • 13,931
  • 30
  • 95
  • 128