Module: Carnival::ModelHelper::ClassMethods

Defined in:
app/models/carnival/model_helper.rb

Instance Method Summary collapse

Instance Method Details

#list_for_checkboxObject



23
24
25
26
27
# File 'app/models/carnival/model_helper.rb', line 23

def list_for_checkbox
  list = []
  all.each {|object| list << [object.id, object.to_label] }
  list
end

#list_for_select(params = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'app/models/carnival/model_helper.rb', line 12

def list_for_select(params = {})
  select = []
  select << ['', ''] if params[:add_empty_option]
  if params[:reverse]
    select.concat all.collect{|c|[c.to_label, c.id]}
  else
    select.concat all.collect{|c|[c.id, c.to_label]}
  end
  select
end