Forum: Ruby on Rails preventing auto-save of related model objects

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
chopper (Guest)
on 2007-03-27 03:25
(Received via mailing list)
How do you prevent Rails from saving many-to-many updates on a model
object?

I have an edit page for a model object which has a table on it
represented
by a has-many relationship.  Each table row consists of a label and a
series
of checkboxes.  I am trying to allow the user to add/remove rows from
this
table (using AJAX), but then either Cancel or Save the updates along
with
the rest of the info on the page.

Whenever the AJAX calls update the backing model, the relationships are
saved in the database rather than held in memory.  Is there a way to
prevent
this, or enable some sort of transaction across http requests, that can
rollback in the case of a cancel?

Or is there a better way to accomplish this?

Thanks,
- chopper
reed (Guest)
on 2007-03-28 02:16
(Received via mailing list)
On Mar 27, 11:24 am, chopper <removed_email_address@domain.invalid> wrote:
> this, or enable some sort of transaction across http requests, that can
> rollback in the case of a cancel?
>
> Or is there a better way to accomplish this?
>
> Thanks,
> - chopper

Transactions across http requests would be a bad thing.  How do you
guarantee commit/rollback happens, prevent records from being locked
indefinately or records from being updated before commit/rollback?

I'm not a ruby expert but I am working on a similar problem and I
posted a question about this 2 weeks ago and got no responses.

I am interested to see how you are handling the many to many in your
rhtml and controller.

If you post your rhtml file and the relevent controller functions I
may be able to help.

Cheers
Reed
This topic is locked and can not be replied to.