Displaying 1 result from an estimated 1 matches for "tail_color".
2006 Aug 16
3
AR: column methods?
...t.column "color", :string
end
If a dog''s tail indicates its own color, I want to use it. Otherwise,
the tail''s color is the same as the dog''s color:
class Dog < AR::Base
has_one :tail
end
class Tail < AR::Base
belongs_to :dog
alias_method :tail_color, :color
def color
return tail_color if tail_color != nil
return dog.tail_color
end
end
The trouble is that the ''color'' method doesn''t exist yet:
$ ./script/console
Loading development environment.
>> x = Tail.new
NameError: undefined method `color'...