Created
April 12, 2010 17:27
-
-
Save kent/363798 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hi all. | |
Trying to do this | |
class Person < ActiveRecord::Base | |
include EasySelectFields | |
easy_select_fields "status", ["Interested", "Not Interested", "Available"] | |
end | |
module EasySelectFields | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def easy_select_fields(a,options) | |
type_method_name = "#{a}_types".to_sym | |
instance_eval do | |
def type_method_name | |
arr = [] | |
count = 1 | |
options.each do |o| | |
arr << [o,count] | |
count += 1 | |
end | |
arr | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment