Class: AtomicAdmin::AtomicTenantPlatformGuidStrategyController

Inherits:
ApplicationController show all
Defined in:
app/controllers/atomic_admin/atomic_tenant_platform_guid_strategy_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

def index

page = AtomicTenant::PinnedPlatformGuid.all.order(:id).paginate(page: params[:page], per_page: 30)
render json: {
  pinned_platform_guids: page,
  page: params[:page],
  total_pages: page.total_pages
}

end



35
36
37
38
# File 'app/controllers/atomic_admin/atomic_tenant_platform_guid_strategy_controller.rb', line 35

def create
  result = AtomicTenant::PinnedPlatformGuid.create!(pinned_platform_guid_params)
  render json: { pinned_platform_guid: result }
end

#destroyObject



52
53
54
55
56
# File 'app/controllers/atomic_admin/atomic_tenant_platform_guid_strategy_controller.rb', line 52

def destroy
  pinned_platform_guid = find_pinned_platform_guid
  pinned_platform_guid.destroy
  render json: { pinned_platform_guid: pinned_platform_guid }
end

#find_pinned_platform_guidObject



11
12
13
# File 'app/controllers/atomic_admin/atomic_tenant_platform_guid_strategy_controller.rb', line 11

def find_pinned_platform_guid
  AtomicTenant::PinnedPlatformGuid.find(params[:id])
end

#pinned_platform_guid_paramsObject



7
8
9
# File 'app/controllers/atomic_admin/atomic_tenant_platform_guid_strategy_controller.rb', line 7

def pinned_platform_guid_params
  params.permit(:iss, :platform_guid, :application_id, :application_instance_id)
end

#searchObject



15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/atomic_admin/atomic_tenant_platform_guid_strategy_controller.rb', line 15

def search
  page = AtomicTenant::PinnedPlatformGuid
    .where(application_instance_id: params[:application_instance_id])
    .order(:id).paginate(page: params[:page], per_page: 30)
  render json: {
    pinned_platform_guids: page,
    page: params[:page],
    total_pages: page.total_pages
  }
end

#showObject



40
41
42
43
# File 'app/controllers/atomic_admin/atomic_tenant_platform_guid_strategy_controller.rb', line 40

def show
  pinned_platform_guid = find_pinned_platform_guid
  render json: {pinned_platform_guid: pinned_platform_guid}
end

#updateObject



45
46
47
48
49
50
# File 'app/controllers/atomic_admin/atomic_tenant_platform_guid_strategy_controller.rb', line 45

def update
  pinned_platform_guid = find_pinned_platform_guid
  pinned_platform_guid.update!(pinned_platform_guid_params)

  render json: {pinned_platform_guid: find_pinned_platform_guid}
end