30 lines
750 B
Ruby
30 lines
750 B
Ruby
class PortfoliosController < ApplicationController
|
|
|
|
def index
|
|
@index_images = PortfolioImage.order("Created_at DESC").limit(20)
|
|
end
|
|
|
|
def show
|
|
@slug = params[:slug]
|
|
|
|
if params[:slug]
|
|
@portfolio = Portfolio.find_by_slug(params[:slug])
|
|
|
|
@images = @portfolio.images.page(params[:page]).per(1)
|
|
|
|
|
|
@prev_page = @images.current_page.to_i > 1 ? @images.current_page.to_i-1 : @images.total_count
|
|
|
|
@next_page = @images.current_page.to_i < @images.total_count ? @images.current_page.to_i+1 : 1
|
|
|
|
|
|
@next_image = @portfolio.images.page(@next_page).per(1).first
|
|
@prev_image = @portfolio.images.page(@prev_page).per(1).first
|
|
|
|
else
|
|
|
|
end
|
|
|
|
end
|
|
end
|