Class: Api::AttachmentsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/alchemy/api/attachments_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/alchemy/api/attachments_controller.rb', line 5

def index
  authorize! :index, Attachment

  @attachments = Attachment.all
  @attachments = @attachments.ransack(params[:q]).result

  if params[:page]
    @attachments = @attachments.page(params[:page]).per(params[:per_page])
  end

  render json: @attachments, adapter: :json, root: "data", meta: 
end