Transactions are just not working

Here’s my method that has the transaction in it:
http://rafb.net/paste/results/yIuwpz49.html

The message, forumobject and groupright are all models within the same
database.

I have some validations for each and my problem is that when the
validation for message fails, other objects still get saved.

Why is this happening?

On Wed, Oct 11, 2006 at 04:51:07PM +0200, RoR newbie wrote:
}
} Here’s my method that has the transaction in it:
} http://rafb.net/paste/results/yIuwpz49.html
}
} The message, forumobject and groupright are all models within the same
} database.
}
} I have some validations for each and my problem is that when the
} validation for message fails, other objects still get saved.
}
} Why is this happening?

Without actually seeing your code, my guess is that you are using MySQL
with MyISAM tables, which do not support transactions. Insert rant here
about how MySQL is a lousy RDBMS.

–Greg

You need to use the .save! method which throws an exception,
or generate your own exception if there’s an error. Transactions
only roll back on an exception.

On Oct 11, 2006, at 7:51 AM, RoR newbie wrote:

Why is this happening?


Posted via http://www.ruby-forum.com/.


– Tom M.

Tom M. wrote:

You need to use the .save! method which throws an exception,
or generate your own exception if there’s an error. Transactions
only roll back on an exception.

Can this be done so that it won’t give me the exception screen but justs
rolls back and goes on?

RoR newbie wrote:

Tom M. wrote:

You need to use the .save! method which throws an exception,
or generate your own exception if there’s an error. Transactions
only roll back on an exception.

Can this be done so that it won’t give me the exception screen but justs
rolls back and goes on?

If you catch the exception in a rescue block and do nothing, yes.

On Oct 11, 2006, at 2:06 PM, RoR newbie wrote:

Tom M. wrote:

You need to use the .save! method which throws an exception,
or generate your own exception if there’s an error. Transactions
only roll back on an exception.

Can this be done so that it won’t give me the exception screen but
justs
rolls back and goes on?

Yes.

That is a given when wrapped in a transaction.


– Tom M.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs