On Feb 10, 2006, at 5:28 PM, Nic W. wrote:
Wow, thats beautiful, thanks for the help! I’m going to change some of
my code now.
No problem. If you call my code beautiful, I’ll help anytime. 
One more thing: How would I handle dynamic jack colors? I have outlets
that contain n jacks with n colors.
The Right™ way to do this would be to have a separate table and model
with the colors in it…
I wouldn’t be able to refer to ‘orange_jack’, but I would want to
display/loop an outlet with all available jacks and their respective
colors.
outlet.jacks.each { |j| j.color.name }
My solution would be to take what you’ve done above, but create a more
generic method, and try to pass it the color value…doesn’t seem
clean though.
If there are a fixed number of colors, just create a method for each
one…
But…why pass in a color if you just want to list all available?
Perhaps for Jack#is_orange? replacement?
With tables as suggested above, like this:
outlet.jacks.first.is_color?(Color.find_by_name(‘orange’))
in Jacks:
def is_color?(match_color)
color.name == match_color.name
end
There is advanced (intermediate?) Ruby that I’m not 100% comfortable
with yet that allows trapping undefined method calls that would allow
automatic handling of:
is_*? method calls dynamically.
Anyone care to enlighten us both? 
–
– Tom M.