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
1 answer

Ruby Datamapper: retrieving record using param in url path returns null - sometimes

I'm creating a Sinatra App using Datamapper. With the following route, I'm attempting to print the record for an id. So localhost:9292/api/1 should return results for id=1 inside get '/api/:id' do I tried a couple things with varied results: …
Pirijan
  • 3,430
  • 3
  • 19
  • 29
0
votes
1 answer

DB reset after pushing to openshift

I have a Sinatra project that I'm publishing through Openshift. Every time I'm pushing the changes to the openshift remote, the datebasse is reset. I'm using sqlite3 with DataMapper From DataMapper init file DataMapper.setup(:default,…
orelzion
  • 2,452
  • 4
  • 30
  • 46
0
votes
1 answer

Sinatra DataMapper one-to-many relationship

Im new to Sinatra, and I have a problem with DataMapper one-to-many relationship db.rb env = ENV["RACK_ENV"] url = Dir.pwd + "/db/#{env}" DataMapper.setup :default, "sqlite://#{url}.sqlite3" class Order include DataMapper::Resource property…
junior
  • 808
  • 15
  • 25
0
votes
1 answer

How does DataMapper's auto_upgrade work?

Can you please tell me how Data Mapper's auto upgrade thing works? For example: include 'data_mapper' DataMapper.setup :default, "sqlite://#{Dir.pwd}/base.db" class User include DataMapper::Resource property :id, Serial property :name,…
0
votes
1 answer

Convert existing DataMapper app data to a different database type

I have an existing ruby application using DataMapper that I am looking to convert to a different database type, preserving the existing data and still using DataMapper. For my specific case, I want to go from sqlite3 with DataMapper to postgress…
0
votes
1 answer

Is there a way to make a DataMapper Enum type be zero based?

Using DataMapper Enum type for the first time, and I noticed the first value in the enum translates to a 1. I need this to be zero based to be backward compatiable with another ORM layer in a different application also reading this database.
Boiler Bill
  • 1,900
  • 1
  • 22
  • 32
0
votes
1 answer

Ruby datamapper associations

I am just learning Ruby and datamapper, I have read the docs about associations from the official DataMapper site, but I still have two problems. First whenever I add associated object, I can not see it when displaying all objects. I have test class…
user3274539
  • 687
  • 2
  • 8
  • 18
0
votes
1 answer

Ruby DataMapper: undefined method `include?'

I am trying an example on the page http://ruby.about.com/od/sinatra/a/datamapper.htm. I copied the following code from the web site: require 'rubygems' require 'dm-core' require 'dm-migrations' DataMapper.setup(:default,…
gefei
  • 18,922
  • 9
  • 50
  • 67
0
votes
3 answers

Ruby on Rails radio button selection to database

Im currently working on a form where the user are able to choose between 1-5 radio button alternatives and then upload what they choose to a database. I'm currently using different name on each radio button and then check which param posted is equal…
David
  • 603
  • 2
  • 6
  • 15
0
votes
2 answers

How to prevent a signup when user already exists Sinatra

I am trying to create a simple sign up form using Sinatra and data mapper that signs up a user only if one already does not exist. The problem seems to be that no user is created using the code below def signup(username, password, email) @user =…
0
votes
1 answer

DataMapper use only certain columns

I have a code section like the following: users = User.all(:fname => "Paul") This of course results in getting all users called "Paul". Now I only need some of the columns available for each user which leads to replacing the above line by something…
Disenchant
  • 118
  • 4
0
votes
1 answer

What is the best way to save an array into a hash dynamically?

DataMapper saves its errors as a Validate::ValidationErrors object. I want to convert those errors to an array and save the errors indexed by the name of the new item being created (category). I am new to Ruby and looking for some guidance in…
user1491929
  • 654
  • 8
  • 16
0
votes
1 answer

How to find all records if one property is equal to another one

Very simple task but I'm confused... For example I've the class: class Test include DataMapper::Resource property :id, Serial property :val1, Integer property :val2, Integer end Is it possible to find all records where val1 = val2 calling…
0
votes
1 answer

DataMapper validation errors with brackets

I'm using DataMapper's validations, but I can't get the error messages text :( I tried: @error = user.errors.first @error = user.errors.full_messages.first @error = user.errors.full_messages.flatten @error = user.errors[0] But still I get an array…
Faery
  • 4,552
  • 10
  • 50
  • 92
0
votes
2 answers

Using attr_encrypted with DataMapper and Sinatra

I'm quite new with DataMapper and Sinatra and especially attr_encrypted. What I want is to store my passwords encrypted and then be able to search for a user by username and password. I read the documentation of attr_encrypted, but I still don't get…
Faery
  • 4,552
  • 10
  • 50
  • 92