Hi, could you suggest me how to handle this in a proper way? I have a table which has othertable_id column (relationship is belongs_to) Problem is, that sometimes there is a NULL value and table.othertable.foo returns an error... what should I do about it? change something in model? in view? or just add "unknown" row to othertable and update table.othertable_id with id of this row? tia, m.
on 2006-01-24 22:06
on 2006-01-24 22:20
Sounds like a case of missing lookup/reference values. have a look at the act as enumeration plugin by Trevor Squires.. http://wiki.rubyonrails.org/rails/pages/Acts+As+En... It allow you to build your own handler for each senario.. :on_lookup_failure def your_lookup_handler(operation, name, name_foreign_key, acts_enumerated_class_name, lookup_value) end you may then choose to have a default values, or an raise an exception whatever.... regards,
on 2006-01-24 22:37
Leon Leslie wrote: > you may then choose to have a default values, or an raise an exception > whatever.... Thanks a lot, I'll check it! m.