Forum: Ruby on Rails setting default on "has_one" failure

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.
F719c6cb34bd5b691c12b373b7244b4d?d=identicon&s=25 Dorian Mcfarland (Guest)
on 2006-01-26 05:07
(Received via mailing list)
Hi there,
I have a model for a Film, which:

  has_and_belongs_to_many :artists
  has_many                :stills
  has_one                 :preview_image,
                          :class_name => "Still",
                          :conditions => "priority='main'"

the has_one:preview_image and has_many:stills obviously draw from the
same table.

I was wondering if there is a way to set a default value for
:preview_image (say :stills[0] for example) if has_one fails to retrieve
a :preview_image from the db?

If it's easier to send me link, then I'd happily read a page about what
you can do to models, as I'm finding it difficult to do very much in the
model pages.

thanks

dorian

--
I do things for love or money
--
+44 (0)7941 219 501
--
aim:oulalipo | yahoo:tachekent
This topic is locked and can not be replied to.