def association(method, collection, value, text, options = {})
      options[:as] ||= :select
      options[:association] ||= {}

      klass = [::Formula.association_class, options[:as]]
      klass << ::Formula.association_error_class if ::Formula.association_error_class.present? and error?(method)

      self.block(method, options) do
        @template.content_tag(::Formula.association_tag, :class => klass) do
          case options[:as]
          when :select then collection_select :"#{method}_id", collection, value, text,
              options[:association], options[:association].delete(:html) || {}
          end
        end
      end
    end
def association(method, collection, value, text, options = {})
      options[:as] ||= :select
      options[:association] ||= {}

      klass = [::Formula.association_class, options[:as]]
      klass << ::Formula.association_error_class if ::Formula.association_error_class.present? and error?(method)

      self.block(method, options) do
        @template.content_tag(::Formula.association_tag, :class => klass) do
          case options[:as]
          when :select then collection_select :"#{method}_id", collection, value, text,
              options[:association], options[:association].delete(:html) || {}
          end
        end
      end
    end
Generate a suitable form association for a given method by performing introspection on the type.

 Options:

 * :label       - override the default label used ('Name:', 'URL:', etc.)
 * :error       - override the default error used ('invalid', 'incorrect', etc.)
 * :association - add custom options to the input ({ :class => 'goregous' }, etc.)
 * :container   - add custom options to the container ({ :class => 'gorgeous' }, etc.)

 Usage:

   f.association(:category, Category.all, :id, :name, :hint => "What do you do?")
   f.association(:category, Category.all, :id, :name, :association => { :prompt => "Category?" })
   f.association(:category, Category.all, :id, :name, :association => { :html => { :class => "category" } })

 Equivalent:

   <div>
     <div class="association category">
       <%= f.label(:category)
       <div class="association">
         <%= f.collection_select(:category, Category.all, :id, :name) %>
       </div>
       <div class="hint">What do you do?</div>
       <div class="error">...</div>
     </div>
   </div>
   <div>
     <div class="association category">
       <%= f.label(:category)
       <div class="association">
         <%= f.collection_select(:category, Category.all, :id, :name, { :prompt => "Category") } %>
       </div>
       <div class="error">...</div>
     </div>
   </div>
   <div>
     <div class="association category">
       <%= f.label(:category)
       <div class="association">
         <%= f.collection_select(:category, Category.all, :id, :name, {}, { :class => "category" } %>
       </div>
       <div class="error">...</div>
     </div>
   </div>