module SelectProductHelper def select_product(object, method, products, options = {}) html = '' brands = {} products.each do |p| if brands[p.brand_id] == nil brands[p.brand_id] = p.brand.name end html<< content_tag('option', "#{brands[p.brand_id]} - #{p.name}", {:value => p.id}) end Binding.of_caller do |binding| concat(content_tag('select', html, {'name' => "#{object}[#{method}]"}), binding) end end end