Sha256: 797d00a6e45c621f347f0cac3bfa6dfeba23dc3e590cd38743eb7bfc14c40f40

Contents?: true

Size: 436 Bytes

Versions: 12

Compression:

Stored size: 436 Bytes

Contents

module Carnival::ModelHelper

  def to_s
    self.name
  end

  def self.included mod
    mod.extend ClassMethods
  end

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
carnival-0.0.43 app/models/carnival/model_helper.rb
carnival-0.0.42 app/models/carnival/model_helper.rb
carnival-0.0.41 app/models/carnival/model_helper.rb
carnival-0.0.40 app/models/carnival/model_helper.rb
carnival-0.0.39 app/models/carnival/model_helper.rb
carnival-0.0.38 app/models/carnival/model_helper.rb
carnival-0.0.37 app/models/carnival/model_helper.rb
carnival-0.0.36 app/models/carnival/model_helper.rb
carnival-0.0.35 app/models/carnival/model_helper.rb
carnival-0.0.34 app/models/carnival/model_helper.rb
carnival-0.0.33 app/models/carnival/model_helper.rb
carnival-0.0.26 app/models/carnival/model_helper.rb