selection_options_for now on github

Mark's Rails plugin for selection_options_for  is now available on github.   More details are in the Extended section.


 

 

# This code allows you to keep the display labels in the model
# when the DB holds only a 1 character flag.
# and when the code requires symbolic references to the value to use in algorithms
#
# element 0 of the array passed in is always the logical symbol
# If a 2-element Array is passed in, [key, label] and the first letter of label is the DB value
# If a 3-element Array is passed in, [key, DB value, label]
# Any other type passed in throws an error
#
# Limitations: Don't use this if you will run reports directly against the DB
# In that case, the reports will not have access to the display labels
#
 
class Article < ActiveRecord::Base
 
        selection_options_for :file_type_option,
           [:pdf,    'PDF'],
           [:hmlt,   'HTML'],
           [:msword, 'MS-Word']
           [:text,   'X', 'Textfile']
end

-- Mark Windholtz

Read more at our BLOG.