similar to: ActiveRecord#touch behaviour in Rails 3

Displaying 20 results from an estimated 40000 matches similar to: "ActiveRecord#touch behaviour in Rails 3"

2006 May 17
0
acts_as_versioned with lock_version bug?
Hello. The acts_as_versioned plugin works fine ... till the adjunction of optimistic locking via the lock_version table column. Here is the problem description: Without optimistic locking things are fine: # ++++ The table creation migration ++++ % cat db/migrate/001_create_tables.rb class CreateTables < ActiveRecord::Migration def self.up create_table :softwares,
2009 Aug 10
1
[PATCH server] Fixed db-omatic so it doesn't die due to an unhandled ActiveRecord::StaleObjectError exception.
The error is caused by the save! method updating an object that another thread (most likely in taskomatic) already updated. In the case of this race condition, we retry saving. However, a proper fix would involve fixing the locking. --- src/db-omatic/db_omatic.rb | 23 ++++++++++++++++++++--- 1 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/db-omatic/db_omatic.rb
2006 Jul 06
4
update_all Not Incrementing lock_version
Shouldn''t update_all be updating lock_version? As you can see from my console session below, it is upating the record (changed running attribute to true and returned 1 to show 1 recored was updated). But it did not increment lock_version. And optimistic locking is working correctly otherwise. As you can see below, lock version = 562 before and after the update_all call but it is
2006 Apr 11
1
Implementing Optimistic Offline Lock - How ?
I understand that ActiveRecord supports the "optimistic offline lock"-pattern through magic fields (created_at, updated_at). However, a scaffolded CRUD-Controller doesn''t generate the necessary code to support this feature (the model state gets lost between two action calls). What is the best practice to prevent users from overwriting objects with outdated data ? --
2006 Jan 04
2
Rename lock_version field?
Hi, Is there a way to tell Rails that the magic field name for optimistic database locking is not lock_version? I have a legacy database where the optimistic locking field is named "version". Thanks, Phil -- Posted via http://www.ruby-forum.com/.
2006 Apr 10
1
random | in join statement with more than one :include
I have an ActiveRecord class that has several has_many,belongs_to, habtm, and the new has_many => :through relationships. Whenever I try a find(:all, :conditions => "some conds", :include [:relationship]) it works fine, but if I have find(:all, :conditions => "some conds", :include [:relationship, :other_relation]) it gets a sql error such as Mysql::Error: You
2006 Jun 05
0
migration to be called inside others migrations
Hi list I''m writing some migrations to move a legacy db on a rails app. I have a bunch of tables which need some custom modifications and the columns updated_at to be added etc... Now since the rails related columns will be the same for many (but not all) tables I was thinking... can I write a Migration that sounds like that class AddRailsFields < ActiveRecord::Migration def
2007 Mar 25
1
Optimistic locking and update_attributes: not working?
Hi all, I''ve searched the forumns, but I can''t seem to find an answer to this one. I''m having trouble getting optimistic locking (OL) to work in my app, even though all of the pieces are there: * table has lock_version column, with default of 0 (zero) * lock_version column is being incremented by the first update (but the second doesn''t catch it) *
2006 May 17
6
ActiveRecord#to_param
Hello, to implement some some kind of optimistic locking, I want to build a view, where an object is displayed together with a link containing the data of the displayed object. My first try looked something like <%= object.object_discription %> <%= link_to "action", :action => "take_action", :data => object %> this won''t work because object is of
2009 Oct 16
5
Rails 2.3 Model.touch(:column) always also updates :updated_at???
Hi, Am I the only one (i.e. something I do is wrong), or does the touch- method always update updated_at, even though giving it a column to use INSTEAD is meant to update just that column??? Thanks, Michael
2009 May 19
4
proper way to ensure atomic model changes
Hi! Say we have a rails active-record-based model called "instance" which can have different states - STOPPED, RUNNING, STARTING_UP, SHUTTING_DOWN, etc... There is a method #start which changes the instance state to STARTING_UP only if it is STOPPED. def start if self.state == STOPPED self.state = STARTING_UP self.save ... end end As you understand if we have multiple
2008 Jan 15
6
SQLite concurrency, SQLite3::BusyException
I am currently experiencing concurrency issues after moving from MySQL to SQLite. My original program worked fined using MySQL but is now returning "SQLite3::BusyException" errors. The same result happens whether or not I enable the allow_concurrency flag. If I do manually acquire a lock on the SQLite DB the problem would disapear, but I thought that rails was supposed to handle this
2008 Nov 13
5
Touch an ActiveRecord - timestamps
When I update an ActiveRecord, i would like to "touch" one of the related objects, that the updated record belongs_to, in order to update the timestamps on the parent record, although i don''t want to change any of the data in the parent. Whats the accepted way to do this? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You
2007 Jul 31
0
Force an object to previous state, when using lock_version
If I have an exception while trying to save an object, how can I tell Rails that it''s not saved yet? The object has a lock_version (used for optimistic locking). This is what I do: ins = MyClass.new( arguments ) begin transaction do ins.save! bunch_of_other_stuff() end rescue ins.save! # problem here! end The object''s save() sets the internal object state in a saved
2007 Jul 08
2
datetime_select, is creating an instance of the Time class
Hello It seems that datetime_select, is creating an instance of the Time class. Why would that be? I found this while building a site where people can create vigils (prayer vigils, peace vigils, etc). When I added a validation method that compared start_date to created_at, it generated the error: ArgumentError (comparison of Time with DateTime failed): I was able to put a breakpoint in the
2010 Nov 18
7
Rails 3 ActiveRecord queries - I'm missing something very BIG
Hi, I know I am missing something very big regarding the changes with respect to activerecord in Rails 3. I can''t find the explanation. And I''m sure someone will kick my ass for not finding the right piece of info in the docs and guides. Please do. I have a working piece of code but I don''t like it. So. Very basic association: class Project < ActiveRecord::Base
2009 Jun 27
1
Problem with :touch in belongs_to
I''ve read in rails api that there is a touch parameter and I want to use it in my application. I have something like that class User < ActiveRecord::Base has_many :phones after_update :updated def updated ... end end class Phone < ActiveRecord::Base belongs_to :user, :touch => true end I want that every change of any phone number would change User updated_at
2013 Feb 25
7
Optimistic Locking Enhancements: Gem or Core?
I''m working on an app that makes use of rails'' optimistic locking feature and seeing some possibilities for improvements. It seems a bit tedious to have to add :lock_version to forms wherever the model is used. You also have to "hack" around rails'' UJS feature to add it as a URL parameter when using remote: true, method: [:put, :patch, :post, :delete].
2009 Aug 10
0
[PATCH server] Fixed db-omatic so it doesn't die due to unhandled exceptions related to saving db objects in update_host_state and update_domain_state.
The underlying issue has to do with optimistic locking for active record, and contention between db-omatic and task-omatic. That still needs to be fixed, especially since contention issues might get worse when the two daemons are made multithreaded. --- src/db-omatic/db_omatic.rb | 22 +++++++++++++++++++--- 1 files changed, 19 insertions(+), 3 deletions(-) diff --git
2006 Sep 04
2
"include" versus "extend" - what's the difference
Hi, Just wondering when one would use "include" over "extend"? Both seem to bring in methods to the class no? The context is I''m just trying to understand why both are used with the acts_as_audited plugin: Full extract from plugin (used within here): ================================================== # Copyright (c) 2006 Brandon Keepers # # Permission is hereby