Hi
Not trying to solve a specific problem here, but have a theoretical
question, anyhow...
Having created a simple model/controller with the scaffold generator, I
created a simple remote client based on ActiveResource.
A part of this code is illegal, but illustrates what I want to accomplish:
require 'active_resource'
class EnvironmentType < ActiveResource::Base
self.site = "http://xxx:3001"
end
etypes = EnvironmentType.find(:all)
puts etypes.map(&:name)
# This part of the code is not legal, based on some code I found for
ActiveRecord
EnvironmentType.transaction do
etypes[0].name = "Prod"
etypes[0].save
etypes[1].name = "Testing"
etypes[1].save
raise ActiveRecord::Rollback
end
# End of illegal part...
etypes = EnvironmentType.find(:all)
puts etypes.map(&:name)
# Assumption is that that the names has not changed at this point...
Basically, my question is if there is some (easy) way to initiate a
transaction from this remote client with the possibility of a rollback after
a set of saves has been done.
OK, so maybe the best/shortest answer is that this is bad design to remotely
initiate a transaction like this, but I'm gonna ask anyway :o)
Best regards,
Rolf
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.