app/controllers/task_manager/api/v1/plans_controller.rb in task-manager-0.1.3 vs app/controllers/task_manager/api/v1/plans_controller.rb in task-manager-0.1.4
- old
+ new
@@ -45,16 +45,15 @@
# "name": ...
# }, ...]
# }, ...]
# }
def index
- plans = TaskManager::Plan.search(params[:q]).result.order('id DESC')
+ plans = TaskManager::Plan.page(params[:page]).per(params[:limit]).
+ order('id DESC').search(params[:q]).result
result = {
- total: plans.count,
- plans: ActiveModel::ArraySerializer.new(
- plans.page(params[:page]).per(params[:limit])
- ).as_json
+ total: plans.total_count,
+ plans: ActiveModel::ArraySerializer.new(plans).as_json
}
render json: result, status: :ok
end
@@ -215,9 +214,10 @@
# ...
# }
# }
def update
plan.assignables.destroy_all
+ plan.callables.destroy_all
if plan.update_attributes(params[:plan])
render json: plan, status: :ok
else
render json: { errors: plan.errors }, status: :unprocessable_entity