Does :autosave do what you want?

has_one :show, :though => :pool, :autosave => false

Or if you never want to save this way, maybe:

has_one :show, :though => :pool, :readonly => true

I haven't tried either, but I remember running across these in one of
the rails guides, so maybe it helps.

On May 28, 5:28 am, Wouter de Bie <[email protected]>
wrote:
> Hi all,
>
> I'm having issues with a has_one :through relationship. I have a setup
> where "Ticket has_one :show, :though => :pool". The thing worked, but
> what I noticed is that as soon as my ticket is saved, the show is also
> saved. In my case this is pretty dangerous, since I'm using optimistic
> locking on the show and since tickets are updated very frequently,
> things can get pretty messy.
>
> Is it possible to turn of this behavior and never save the associated
> model? In my case, the show is never set directly on the ticket
> (ticket.show = Show.find(x) is never done), so I've worked around it by
> just creating a method "show" that returns pool.show, but I don't really
> like this solution, since I also use the relation in some API code that
> figures out what to return by inspecting the model.
>
> Regards,
>
> Wouter
> --
> Posted viahttp://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 [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
-~----------~----~----~----~------~----~------~--~---

Reply via email to