Displaying 20 results from an estimated 200 matches similar to: "Rename lock_version field?"
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
2008 Oct 21
1
How to force a lock_version increment
Hi everyone,
I have a order with order_lines use case. On changing the lines, I
want to be sure no one else changed the order. So I use lock_version
on the order. This works fine if something is changed on the order
record.
But now i have the situation that I delete, alter and add order lines
without changing the order record itself. I have to check and
increment the order#lock_version however
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
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,
2006 Jan 06
0
[PATCH] [3402] Allow lock_version column name to be configured.
My first stab at the whole metaprogramming / DSL thing. Fun stuff.
Includes unit tests, fixtures, etc, etc. Tested against Oracle and
PostgreSQL so far. I''d appreciate it if some MySQL folks could try it
out. Hopefully I got the MySQL CREATE TABLE syntax correct.
http://dev.rubyonrails.org/ticket/3402
Assuming this kind of thing is OK, I''d like to make
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].
2006 Feb 23
7
Session Based Record Locking - Solutions?
All,
I''ve written a simple job/opportunity tracking database app via RoR.
I have about 10 internal users.
Sometimes 2 people will want to update the same record at more or less
the same time and they collide.
In particular user 1 may edit a record, then get distracted, and
finally an hour later they click save.
During that hour user 2 may have pulled up the record, edited it, and
2006 May 09
7
When to use optimistic locking?
Hi All,
I''m having some trouble deciding when and how to implement optimistic
locking.
Let''s say I have a multiuser Rails app, and let''s say it stores,
among other things "vital" customer information.
The standard methods created by the Rails generate scaffold script
look like this:
def edit
@customer = Customer.find(params[:id])
end
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
2006 Jan 12
9
Scaffold shows all attributes altough I use attr_accessible!
Hi all
I have a Model like this:
class Member < ActiveRecord::Base
attr_accessible :username, :email, :first_name, :last_name
end
I have created a scaffold using script/generate scaffold member members
Using the URL localhost:3000/members/edit/1 I can edit all attributes,
including created_at, lock_version etc.! But it should only show the
attributes I listed in attr_accessible!
What
2012 Nov 12
3
Updating objects in arrays
Perhaps this is a Rails issue. However, I need to first determine whether
I simply am missing something about updating members of an array.
I have an array of 10 ActiveRecord objects. I wish to iterate over the
array and update an attribute. When I do this the underlying table row
changes but the object in the array frequently does not. For example:
count = 0
current_entries.each do
2005 Apr 04
10
Encrypted ASP.Net type viewstate
Does rails have any builtin functionality similar to that of ASP.Net''s
encryptable ViewState? For those that don''t know what the ASP.Net viewstate
is, it is essentially just a hidden form field with the name __VIEWSTATE,
that stores a series of encoded(or encrypted) key/value pairs as it''s value.
When the form is submitted the viewstate value is decoded/decrypted on the
2006 Jan 20
2
The New Memcache ?
Hey All !
I ended up browsing to Eric Hodel''s blog the other night, and found his
entry about the new cache_model and memcache-client.
Now, it looks like it''s "officially" out in the open:
http://weblog.rubyonrails.com/articles/2006/01/20/caching-models-with-memcached
In my application, I''ve been staying away from caching my models, and
instead just doing
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
2010 Jan 21
2
nested forms and attr_accessable
Rails 2.3.5
I am working on a nested form that assigns roles to users through a
table called clearances. I have attr_acessable turned off globally in
an initializer:
ActiveRecord::Base.send(:attr_accessible, nil)
I have this set in clearance.rb
attr_accessible(:description,
:effective_from,
:role_id,
:superceded_after,
:user_id)
And this is what params looks like after the
2007 Dec 17
3
not able to view the images after the upload
hi,
i have this problem where in i''m able to upload the images using
file_column
to the server but i''m not able to view the images.i''m not able to see
the images
but then i''m able to view the image name when i click on my show action.
can any one please help??
THIS IS MY LOG as to what happens when i do the image upload.
Processing UploadController#create
2007 Apr 20
2
Caching of database values
If do something like this:
dbObj = MyTable.find_by_id(5)
a = dbObj.name
b = dbObj.name
How many times will an SQL call be made to get the value of
MyTable.name for id 5? In other words, are the values for dbObj
cached in the object? Is there a way of controlling that? (I can
imagine that sometimes you might not want to cache them if you wanted
to be sure of having the latest
2009 Dec 17
2
RFC: conflict_warnings plugin
Greetings,
I was hoping to get some feedback on a plugin I wrote.
The plugin is called conflict_warnings and is currently available from
my github repository at http://github.com/EmFi/conflict_warnings
The purpose of the plugin is to provide a simple methods of preventing
data inconsistencies that could arise from multiple users interacting
with the same resource.
Under basic operation a
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
2007 Oct 15
6
SQL injection with :order, :limit, :group
I know how to avoid SQL injection attacks when you use :conditions
User.find :first, :conditions => ["login=?", params[:username]]
but how about with :order, :limit or :group?
# uh-oh...spaghetti-oh
User.find :first, :order => "login; delete from users; select * from users"
Pat
--~--~---------~--~----~------------~-------~--~----~
You received this message because you