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+Enumerated+Plugin
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 1/24/06, MarcinJ <marcinj@portfolio.art.pl>
wrote:>
> 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.
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
--
First they laugh at you, then they ignore you, then they fight you.
Then you win.
-- Mahatma Karamchand Gandhi
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060124/d4ca5950/attachment.html