summaryrefslogtreecommitdiff
path: root/app/controllers/cakes_controller.rb
blob: 9d4a5ef123f0c8b8566798811fc34908f4b6e1f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class CakesController < ApplicationController
  def initialize(repository = Spank::IOC.resolve(:cakes))
    @repository = repository
    super()
  end

  def index
    @cakes = @repository.search_with(params).
      distinct.
      includes([:photos]).
      page(page).per(per_page)
  end

  def show
    @creation = Creation.find(params[:id])
    @primary_image = params[:photo_id].present? ? @creation.photos.find(params[:photo_id]) : @creation.primary_image
  end
end