class PaymentType < ActiveRecord::Base
def self.get_payment_types
payment_types_all = find(:all, :select => "display_name,
stored_name" , :order => :display_name)
# Creates a nested array of [[display_name,
stored_name],[display_name, stored_name]]
payment_types = payment_types_all.map {|item| [item.display_name,
item.stored_name]}
end
# must be defined after the method. Can't be defined in a method
PAYMENT_TYPES = get_payment_types
end
Here is some code that works fine, but I don't understand the need for
the self reference in the def, I will get an undefined variable or
method error.
I don't understand why I need the self when I am inside the class and I
don't understand if I need the self, why I can't use
self.get_payment_types
Thanks
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---