lib/formtastic.rb
def find_collection_for_column(column, options)
      reflection = find_reflection(column)

      collection = if options[:collection]
        options.delete(:collection)
      elsif reflection || column.to_s =~ /_id$/
        parent_class = if reflection
          reflection.klass
        else
          ::ActiveSupport::Deprecation.warn("The _id way of doing things is deprecated. Please use the association method (#{column.to_s.sub(/_id$/,'')})", caller[3..-1])
          column.to_s.sub(/_id$/,'').camelize.constantize
        end

        parent_class.find(:all)
      else
        create_boolean_collection(options)
      end

      collection = collection.to_a if collection.is_a?(Hash)

      # Return if we have an Array of strings, fixnums or arrays
      return collection if collection.instance_of?(Array) &&
                           [Array, Fixnum, String, Symbol].include?(collection.first.class)

      label = options.delete(:label_method) || detect_label_method(collection)
      value = options.delete(:value_method) || :id

      collection.map { |o| [o.send(label), o.send(value)] }
    end
# Used by select and radio inputs. The collection can be retrieved by
# three ways:
#
# * Explicitly provided through :collection
# * Retrivied through an association
# * Or a boolean column, which will generate a localized { "Yes" => true, "No" => false } hash.
#
# If the collection is not a hash or an array of strings, fixnums or arrays,
# we use label_method and value_method to retreive an array with the
# appropriate label and value.
#
Used by select and radio inputs. The collection can be retrieved by
three ways.

Explicitly provided through :collection
Retrivied through an association
Or a boolean column, which will generate a localized { "Yes" => true, "No" => false } hash.

If the collection is not a hash or an array of strings, fixnums or arrays,
we use label_method and value_method to retreive an array with the
appropriate label and value.
Used by select and radio inputs . The collection can be retrieved by three ways . Explicitly provided through : collection Retrivied through an association Or a boolean column which will generate a localized { " Yes " = > true " No " = > false } hash . If the collection is not a hash or an array of strings fixnums or arrays we use label_method and value_method to retreive an array with the appropriate label and value .
def find_collection_for_column(column, options)
      reflection = find_reflection(column)
      collection = if options[:collection]
        options.delete(:collection)
      elsif reflection || column.to_s =~ /_id$/
        parent_class = if reflection
          reflection.klass
        else
          ::ActiveSupport::Deprecation.warn("The _id way of doing things is deprecated. Please use the association method (#{column.to_s.sub(/_id$/,'')})", caller[3..-1])
          column.to_s.sub(/_id$/,'').camelize.constantize
        end
        parent_class.find(:all)
      else
        create_boolean_collection(options)
      end
      collection = collection.to_a if collection.is_a?(Hash)
      return collection if collection.instance_of?(Array) &&
                           [Array, Fixnum, String, Symbol].include?(collection.first.class)
      label = options.delete(:label_method) || detect_label_method(collection)
      value = options.delete(:value_method) || :id
      collection.map { |o| [o.send(label), o.send(value)] }
    end
def find_collection_for_column ( column , options ) reflection = find_reflection ( column ) collection = if options [ :collection ] options . delete ( :collection ) elsif reflection || column . to_s =~ / _id$ / parent_class = if reflection reflection . klass else :: ActiveSupport :: Deprecation . warn ( "The _id way of doing things is deprecated. Please use the association method (#{column.to_s.sub(/_id$/,'')})" , caller [ 3 .. - 1 ] ) column . to_s . sub ( / _id$ / , '' ) . camelize . constantize end parent_class . find ( :all ) else create_boolean_collection ( options ) end collection = collection . to_a if collection . is_a? ( Hash ) return collection if collection . instance_of? ( Array ) && [ Array , Fixnum , String , Symbol ] . include? ( collection . first . class ) label = options . delete ( :label_method ) || detect_label_method ( collection ) value = options . delete ( :value_method ) || :id collection . map { | o | [ o . send ( label ) , o . send ( value ) ] } end
Used by select and radio inputs.
Used by select and radio inputs .
# Return if we have an Array of strings, fixnums or arrays
column
options