Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/form_fu.rb

Class Method Summary collapse

Class Method Details

.to_select(method = 'to_s', conditions = nil) ⇒ Object

find all items matching condition, and return an array of [value,key], useful for using with select



17
18
19
# File 'lib/form_fu.rb', line 17

def self.to_select(method='to_s', conditions=nil)
  find(:all, :conditions => conditions).collect{|record| [record.send(method), record.id]}
end