11155
(-- --)
May 18, 2010, 4:54pm
21
Sharagoz wrote:
You are right, creating a database table for something like this does
feel like overkill. Personally, I often use constants if it's a very
small amount of data.
class Image
VALID_IMAGE_TYPES = ['png', 'gif', 'jpg']
end
Good idea.
or
IMAGE_TYPES = {:1 => 'Photo', :2 => 'Document', :3 => 'Print'}
Not a good idea -- why use :1, :2, :3 instead of actual numbers or
symbolic keys?
Best,
Yes - in my own file_attachment object, I use the same constant!
Sharagoz
(Sharagoz)
May 18, 2010, 5:10pm
23
Not only is it a bad idea, it's invalid ruby syntax. Integers cant be
symbols.
rab
(Rob Biedenharn)
May 18, 2010, 6:11pm
24
'Print' }
=> {:"3"=>"Print", :"1"=>"Photo", :"2"=>"Document"}
But that's not really making the idea any better
-Rob
Rob Biedenharn
http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
rab@GaslightSoftware.com