app/controllers/ishapi/galleries_controller.rb in ishapi-0.1.8.214 vs app/controllers/ishapi/galleries_controller.rb in ishapi-0.1.8.215
- old
+ new
@@ -15,19 +15,41 @@
end
@galleries = @galleries.page( params[:galleries_page] ).per( 10 )
end
def show
- @gallery = ::Gallery.unscoped.find_by :slug => params[:slug]
+ @gallery = ::Gallery.unscoped.where( slug: params[:slug] ).first
+ @gallery ||= ::Gallery.unscoped.where( id: params[:slug] ).first
authorize! :show, @gallery
- if @gallery.premium?
- if @current_user&.profile&.has_premium_purchase( @gallery )
- render 'show_premium_unlocked'
- else
- render 'show_premium_locked'
+
+ @photos = @gallery.photos.order_by( ordering: :asc )
+ respond_to do |format|
+ format.json do
+
+ if @gallery.premium?
+ if @current_user&.profile&.has_premium_purchase( @gallery )
+ render 'show_premium_unlocked'
+ else
+ render 'show_premium_locked'
+ end
+ else
+ render 'show'
+ end
+
end
- else
- render 'show'
+ format.html do
+
+ if @gallery.premium?
+ if @current_user&.profile&.has_premium_purchase( @gallery )
+ render 'show_premium_unlocked'
+ else
+ render 'show_premium_locked'
+ end
+ else
+ render 'show'
+ end
+
+ end
end
end
end
end