Thanks. dm-adjust looks like the right plugin, although it would be
nice for it to support an instance method adjust() so one could call
model_object.adjust(). I don't know if that is being planned for a
future release, but I'm looking at how difficult it would be to modify
the plugin.

Andrew S.


On Nov 13, 1:22 am, ban there <[EMAIL PROTECTED]> wrote:
> try this gemhttp://github.com/sam/dm-more/tree/master/dm-adjust
>
> YourModel.all(:id => 1).adjust!(:counter => 1)
>
> On 11월13일, 오후4시32분, __andrew <[EMAIL PROTECTED]> wrote:
>
> > Hey All,
>
> > I've recently switched from using ActiveRecord to DataMapper and the
> > minor differences have made it a smooth transition so far. However, I
> > can't seem to find any documentation on maintaining a counter. I have
> > an integer column in my model that needs to be incremented
> > periodically. My first inclination was to use model.update_attributes
> > (), but this seems to be a bad idea because the database value could
> > be overwritten before DataMapper can write. The SQL query:
>
> > UPDATE table_name SET counter = counter + 1 WHERE id = n;
>
> > accomplishes what I want to do. I've perused the DataMapper code and
> > docs, but I can't seem to find a method that will abstract this.
> > ActiveRecord's is called 'increment_counter'. Am I missing the simple
> > way to do this?
>
> > Andrew S.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to