Skip to content

Instantly share code, notes, and snippets.

@eric
Forked from obrie/credit_card_type.rb
Created September 7, 2008 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eric/9291 to your computer and use it in GitHub Desktop.
Save eric/9291 to your computer and use it in GitHub Desktop.
class CreditCardType < ActiveRecord::Base
acts_as_enumeration :lookup_name
column :name
def initialize(attributes = nil)
super
self.lookup_name ||= name.to_s.gsub(/[^A-Za-z0-9-]/, '').underscore
end
create :id => 1, :name => 'Visa'
create :id => 2, :name => 'Mastercard'
create :id => 3, :name => 'American Express', :lookup_name => 'amex'
create :id => 4, :name => 'Discover'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment