Class: AtomicAdmin::AtomicTenantDeploymentController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- AtomicAdmin::AtomicTenantDeploymentController
- Defined in:
- app/controllers/atomic_admin/atomic_tenant_deployment_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #deployment_params ⇒ Object
-
#destroy ⇒ Object
render json: find_deployment end.
- #find_deployment ⇒ Object
- #search ⇒ Object
- #show ⇒ Object
Instance Method Details
#create ⇒ Object
def index
page = AtomicTenant::LtiDeployment.all.order(:id).paginate(page: params[:page], per_page: 30)
render json: {
deployments: page,
page: params[:page],
total_pages: page.total_pages
}
end
56 57 58 59 |
# File 'app/controllers/atomic_admin/atomic_tenant_deployment_controller.rb', line 56 def create result = AtomicTenant::LtiDeployment.create!(deployment_params) render json: { deployment: result } end |
#deployment_params ⇒ Object
3 4 5 |
# File 'app/controllers/atomic_admin/atomic_tenant_deployment_controller.rb', line 3 def deployment_params params.permit(:iss, :deployment_id, :application_instance_id) end |
#destroy ⇒ Object
render json: find_deployment end
73 74 75 76 77 |
# File 'app/controllers/atomic_admin/atomic_tenant_deployment_controller.rb', line 73 def destroy deployment = find_deployment deployment.destroy render json: { deployment: deployment } end |
#find_deployment ⇒ Object
7 8 9 |
# File 'app/controllers/atomic_admin/atomic_tenant_deployment_controller.rb', line 7 def find_deployment AtomicTenant::LtiDeployment.find_by(id: params[:id]) end |
#search ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/atomic_admin/atomic_tenant_deployment_controller.rb', line 11 def search tenant_deployments = AtomicTenant::LtiDeployment. where(application_instance_id: params[:application_instance_id]). joins("LEFT OUTER JOIN public.atomic_lti_deployments"\ " ON atomic_tenant_lti_deployments.iss = atomic_lti_deployments.iss"\ " AND atomic_tenant_lti_deployments.deployment_id = atomic_lti_deployments.deployment_id"). order(:id). paginate(page: params[:page], per_page: 30) rows = tenant_deployments.pluck( "atomic_tenant_lti_deployments.id", "atomic_tenant_lti_deployments.iss", "atomic_tenant_lti_deployments.deployment_id", "atomic_tenant_lti_deployments.application_instance_id", "atomic_lti_deployments.client_id", "atomic_lti_deployments.platform_guid", ) page = rows.map do |row| { id: row[0], iss: row[1], deployment_id: row[2], application_instance_id: row[3], client_id: row[4], platform_guid: row[5], } end render json: { deployments: page, page: params[:page], total_pages: tenant_deployments.total_pages, } end |
#show ⇒ Object
61 62 63 64 |
# File 'app/controllers/atomic_admin/atomic_tenant_deployment_controller.rb', line 61 def show deployment = find_deployment render json: { deployment: deployment } end |