class Item
include DataMapper::Resource
property :id, Serial
property :title, String
end
item = Item.new(:title => 'Title 1') # :id => 1
item.save
item_clone = Item.first(:id => 1).clone
item_clone.save
This does "clone" the object as described but how can this be done so it applies a different ID once the record is saved, e.g...
So I'm using the following:
$r = new Record();
$r->select('ip, count(*) as ipcount');
$r->group_by('ip');
$r->order_by('ipcount', 'desc');
$r->limit(5);
$r->get();
foreach($r->all as $record)
{
echo($record->ip." ");
echo($record->ipcount." <br />");
}
Standard:
SELECT `ip`, count...
CodeIgniter claims do sanitize POST variables. I'm also using DataMapper which I believe also does it's own thing. I would like to double check to make sure it's doing what it's supposed to be doing. How can I do this?
I'd like to test this without destroying anything, would typing random escaped characters work? What should I see enter...
I'm working on extending a framework currently implementing an Active Record pattern. The implementations provides a store/save method on the ActiveRecord class. I guess much of this implementation would be the responsibility of the unit of work implementation, like figuring out when and what object relations to save and so on?
How doe...
I know Domain Models and Data Mappers are the OOP snob's choice (using 'snob' in a complementary way, as Martin Fowler calls himself one) - however, even Fowler says in POEAA that
"Active Record is a good choice for domain logic that isn't too complex..."
I have a simple product and invoice domain model, not too many tables/objects...
I'm just diving into Datamapper (and Sinatra) and have a question about associations. Below are some models I have. This is what I want to implemented. I'm having an issue with Workoutitems and Workout. Workout will be managed separately, but Workoutitems has a single workout associated with each row.
Workout - just a list of types...
Consider a database(MSSQL 2005) that consists of 100+ tables which have primary keys defined to a certain degree. There are 'relationships' between tables, however these are not enforced with foreign key constraints.
Consider the following simplified example of typical types of tables I am dealing with. The are clear relations between t...
It is easy to setup Datamapper with a Sqlite3 in memory database with:
DataMapper.setup :default, 'sqlite3::memory:'.
However, when testing, I'd like to destroy the whole in memory database after each test, instead of invoking automigrate! as a shortcut on dropping everything. Is it possible? Or is it enough to set the default repositor...
I've changed my model from
class Place
include DataMapper::Resource
has n, :trails
property :id, Serial
property :name, String, :length => 140
property :tag, String, :required => true
timestamps :at
end
to
class Place
include DataMapper::Resource
has n, :trails
property...
I have managed to run a basic rails app1 on App Engine using:
http://gist.github.com/268192
So, on my basic app2, I install CE, which works fine on local machine.
(communityengine.org)
But, when I follow the same steps on my actual app2, where
community_engine plugin is installed and all the gems are frozen, the
app engine installer sc...
Hi,
I'm trying to migrate my app from MySql to Postgresql, using Rails3-pre and the latest DataMapper.
I have several models which are related through many-to-many relationships using :through => Resource, which means that DataMapper creates a join table with foreign keys for both models. I can't auto_migrate! these changes, because I...
Hello,
i've the following code and tried the whole day to refactor the class methods to a sperate module to share the functionality with all of my model classes.
Code (http://pastie.org/974847):
class Merchant
include DataMapper::Resource
property :id, Serial
[...]
class << self
...
I'm trying to move a simple Sinatra app over to Heroku. Migration of the Ruby app code and existing MySQL database using Taps went smoothly, but I'm getting the following Postgres error:
PostgresError - ERROR: operator does not exist: text = integer
LINE 1: ...d_at", "post_id" FROM "comments" WHERE ("post_id" IN (4, 17,...
...
This is a follow-up to a question I'd asked earlier which phrased this as more of a programming problem than a database problem.
http://stackoverflow.com/questions/2935985/postgres-error-with-sinatra-haml-datamapper-on-heroku
I believe the problem has been isolated to the storage of the ID column in Heroku's Postgres database after run...
Let's say I have a data mapper function that aggregates multiple tables and generates an object instance from that data. The mapper has a typical save() method which delegates to update/insert.
When the mapper executes save - ideally it isolates object fields that have been modified, thus preventing the code from blanket bombing the da...
I've got a single table inheritance structure in my application whereby Admins and Mods extends a User class. The table uses a discriminator value so each record has a type of either "admin" or "mod"
When it comes to finding a user (on login) I'd like to write the following:
current_user = User.find(params[:email => email])
However, ...
Hi,
I have a ruby model that contains a date attribue which I'd like to be able to pass in as a parameter in the format dd/MM/yyyy.
However, my sqlite3 db stores the data in yyyy-MM-dd format so when a date like 20/10/2010 gets passed in, it will not be read to the database.
I am using the Sinatra framework and using haml for the mark...
I am new to CodeIgniter, and I need a way to get more meaningful error messages. Specifically I am having trouble with some model relationships, but the error is vague. I am willing to try/install anything since I dont know how to fix this relationship.
Is there a way to specify how verbose an error message is? Also, this could be relat...
I am beginner to datamapper and I am having trouble resolving the following problem.
I am trying to create two tables with 1 to many relationship.
Table 1: with a composite key of (A, B, C)
Table 2: with a composite key of (A, B, C, D)
With A, B, C foreign key constraint to Table 1.
A, B, C, D make a composite key for table 2.
T...
I'm running an import script which imports a CSV dump of a database into a local sqlite database using DataMapper.
My models look like this:
class Staff
include DataMapper::Resource
property :staff_id, String, :key => true
property :full_name, String
end
class Project
include DataMapper::Resource
property :pro...