Skip to content

Instantly share code, notes, and snippets.

@obrie
Forked from eric/credit_card_type.rb
Created September 7, 2008 18:15
Show Gist options
  • Save obrie/9293 to your computer and use it in GitHub Desktop.
Save obrie/9293 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