Files
openfoodnetwork/app/controllers/enterprises_controller.rb
Rohan Mitchell 7640eb497a Merge branch 'supplied-active-products-on-hand'
Conflicts:
	app/controllers/application_controller.rb
	app/models/enterprise.rb
	app/views/spree/products/_source_sidebar.html.haml
	spec/features/consumer/distributors_spec.rb
	spec/models/enterprises_spec.rb
2013-07-29 11:05:42 +10:00

35 lines
828 B
Ruby

include Spree::ProductsHelper
class EnterprisesController < BaseController
def index
@enterprises = Enterprise.all
end
def suppliers
@suppliers = Enterprise.is_primary_producer
end
def distributors
@distributors = Enterprise.is_distributor
respond_to do |format|
format.js do
@distributor_details = Hash[@distributors.map { |d| [d.id, render_to_string(:partial => 'enterprises/distributor_details', :locals => {:distributor => d})] }]
end
format.html do
@distributors
end
end
end
def show
options = {:enterprise_id => params[:id]}
options.merge(params.reject { |k,v| k == :id })
@enterprise = Enterprise.find params[:id]
@searcher = Spree::Config.searcher_class.new(options)
@products = @searcher.retrieve_products
end
end