Created
August 14, 2012 19:39
-
-
Save amandarae/3352114 to your computer and use it in GitHub Desktop.
refactor to be scalable (ruby iteration)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def my_deals | |
#@orders = @current_user.orders.joins(:brand).where{|q| q.brand.slug == @current_brand.slug }.ordered.order('created_at DESC').paginate(:page => params[:page], :per_page => 10) | |
#other_brands = @current_user.orders.ordered.joins(:brand).includes(:brand).where{|q| q.brand.slug != @current_brand.slug }.map{|o| o.brand}.uniq | |
#@other_brands = BrandDecorator.decorate(other_brands) | |
@brands = SimpleBrand.all + NormalBrand.all | |
@orders = Array.new | |
@brands.each do |b| | |
@orders << @current_user.orders.ordered.joins(:brand).where{|q| q.brand.slug == b.slug}.ordered.order('created_at DESC').paginate(:page => params[:page], :per_page => 3) | |
end | |
@brands = BrandDecorator.decorate(@brands) | |
render 'users/orders/index' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment