search for: old_b_attr

Displaying 1 result from an estimated 1 matches for "old_b_attr".

2006 Feb 19
0
Handling nil attributes in views
...;%= A.B.b_attr || "Value not available" %> B is an optional attribute, i.e., it is not required to be set, so this throws an exception under those circumstances. Option 1: <%= A.B.b_attr rescue "Value not available" %> Option 2: Define the reader for B_attr alias old_b_attr b_attr def b_attr if self.b_attr_id.nil? B.new # essentially, create a new empty version else old_b_attr end end BTW, I''m using the alias method because read_attribute does not work (afaik) with fkey relationships. Both of these methods work, but still don''t qu...