Displaying 20 results from an estimated 30000 matches similar to: "transaction not working with update_attributes!"
2011 May 08
1
Transaction - but no rollback?
Hello,
I''m having trouble with transactions with rails 3.0.3 and mysql 5. I''d
like to import data etl-batch-style:
class Job < ActiveRecord::Base
# ...
def perform_etl
connection.transaction do
extract # some connection.execute / job.update_attribute stuff
transform # some connection.execute / job.update_attribute stuff
end
end
#...
end
2006 Oct 03
2
Rails transactions issue with rollback.
Hi,
I have a transaction in which a duplicate key exception is being thrown
by MySQL. I assume this happens when I try to do a save. The problem
is that before the save, I do a destroy on another object as part of the
transaction. Catching the exception by doing this,
User.transaction do
begin
objA.destroy
objB.save <-- causing exception
rescue Exception => exc
2006 Jun 13
4
When saving parent fails, children will still be updated
Hi all,
When submitting a master/detail form I first want to handle the children
before saving the parent.
There are has_many and belongs_to relations between the parent and the
children, so I can edit the children using (psuedo-)code like:
child.destroy for deleting, child.update_attributes for updating and
@parent.children.push(child) for adding child-records.
I update the parent by using:
2007 Jun 30
3
transactions with two models
Hi,
In Agile Web Development with Rails section on Transactions (p 381)
there are two main examples.
1) making changes in two records in the same database table
2) making changes in two records each in a different *database*
I want to do what is in between: changes in two records each in a
different table of the same database. Suppose they are apples and
oranges tables.
How do I write this?
2006 May 19
2
update_attributes
My application is so far mostly built from scaffold.
When I edit an existing record (I''ve turned off validation) the update
method is called. I get this error:
NoMethodError in <module>/<controller>#update
You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.+
I get the same error when
2010 Jul 23
7
fail rollback transaction with manual raise exception
With :
PostgreSQL 8.4 or postgresql-8.3
rails 2.3.4
pg 9.x or pg 8.x
I test this code:
=========================
class NkiBatch < ActiveRecord::Base
Bank.connection.transaction do
bank = Bank.new(:name => "ddsjdsjdsjk")
bank.save!
raise ActiveRecord::Rollback.new
end
end
and this:
=========================
class NkiBatch < ActiveRecord::Base
2010 Dec 08
2
Bug in nested transactions in rails 2.3.x
Hello!
According to ActiveRecord transactions documentation,
User.transaction do
User.create(:username => ''Kotori'')
User.transaction(:requires_new => true) do
User.create(:username => ''Nemu'')
raise ActiveRecord::Rollback
end
end
User.find(:all) # => Returns only Kotori
But I get both records in database (tested on
2010 Sep 01
0
Error on update_attributes with HABTM relationship
Hope someone can tell me what''s up, because this has me baffled.
I have an Image model, and a Provider model. Both are defined as
"has_and_belongs_to_many" relating to each other. In my image form
partial, I have a bit of AJAX generating the provider_ids array
dynamically from a provider AJAX search on the same page.
So for example, each time I click on a provider name that
2006 May 31
7
Rails, Transactions, and statements
Hi, I have a problem where I need an auto-incremented id back from the
database for a statement that has yet to be committed. The operation
that uses the id may fail, and if so, I need to rollback the database.
I can''t figure out how to send only the statement to the database
without the commit without sending over hard coded SQL. This is what I
started out with:
1 def add_album
2005 Nov 19
14
FULLTEXT search in MySQL on rails
I tried adding a FULLTEXT search index to a table of mine in MySQL,
only to discover that the InnoDB table format doesn''t seem to support
this feature. Switching to the MyISAM table type seemed to work, but
I seem to have some recollection that ActiveRecord transactions aren''t
fully atomic on MyISAM tables. Is this true or am I just remembering
wrong? If so, does anyone have
2009 Jan 06
2
Update_attributes on multiple models, revert back on error
Hi,
I have one method, ''updateStuff'', that will call ''update_attributes''
on 3 different models in the DB.....
How can I account for validation to revert back all updates if one of
the models is not valid?
I''ve looked into Model.valid? which doesn''t seem to work for me ..
Any idea?
Thanks
2006 Jan 06
4
Are migrations executed within a transaction?
Hi all,
Can I safely assume that each migration is excuted within a
transaction, so that''s it''s safe to have migrations executing failing
statements?
Thanks,
- Rowan
--
Morality is usually taught by the immoral.
2006 Sep 04
3
Having trouble with update_attributes() after member access
I''m having problems in a controller i am writing. i get this exception:
wrong number of arguments (1 for 0)
## this does not work:
@voicemail_user = VoicemailUser.find(session[:asterisk][:user_id])
if (@voicemail_user.password == params[:pwd][:current])
@voicemail_user.update_attributes({"password" =>
params[:pwd][:newpwd2]})
end
## but this works:
2006 Jul 11
3
update_attributes and save!
I notice that ActiveRecord::Base.update_attributes() calls save().
What if I want to get an exception if the save fails? Is there a way to
get the update_attributes() function plus the save! function?
Thanks,
Wes
--
Posted via http://www.ruby-forum.com/.
2006 Oct 21
3
Transactions
Ok, how does everyone else do transactions in development mode? If I
get a exception within a transaction, I get the ruby exception screen,
I want rails to complete the block code, and then rollback the
transaction. Is there a way to disable the exception screen before the
transaction, and then enable it after the transaction?
Thanks!
--~--~---------~--~----~------------~-------~--~----~
You
2009 Nov 10
12
[RFC] big fat transaction ioctl
Hi all,
This is an alternative approach to atomic user transactions for btrfs.
The old start/end ioctls suffer from some basic limitations, namely
- We can''t properly reserve space ahead of time to avoid ENOSPC part
way through the transaction, and
- The process may die (seg fault, SIGKILL) part way through the
transaction. Currently when that happens the partial transaction will
2006 Oct 20
2
how do you manually cause a rollback in a transaction?
how do you manually cause a rollback in a transaction?
I''ve looked everywhere with no suceess. Anyone know?
Thanks in advance
Chris
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
2015 Nov 05
1
synthesizing yum transactions
Ok, I'm trying way too hard to shovel myself out of a hole.
We have a bunch of remote CentOS 6 servers, that were configured
with kickstart.
They've subsequently had additional RPMs installed/updated via the
'rpm' utility.
We have reason to occasionally rewind the state of the server back
to it's original set of RPMs.
Of late, we've found that 'yum' handles this
2009 Feb 03
1
update_attributes! does not update nested model
Hi!
I have updated my app to rails 2.3. I have form that has few nested
models and I am happy that I can just write
accepts_nested_attributes_for :tasks, :allow_destroy => true, but
update_attributes! does not update my nested model. I have tried
update_attributes, and it works. Any ideas?
Few lines from log:
update_attributes:
SQL (0.1ms) BEGIN
Education Update (0.3ms) UPDATE
2005 Mar 31
4
Transactions
I cant seem to find much information apart from the basics on
transactions in rails. I have 5 nested transactions, and am performing
the following basic operations:
@whatever1.transaction do
@whatever2.transaction do
....
@whatever2.something = "foo"
@whatever1.something = "bar"
@whatever1.save
@whatever2.save
.....
end
end
((( I had tried using