app/controllers/motor/queries_controller.rb in motor-admin-0.1.57 vs app/controllers/motor/queries_controller.rb in motor-admin-0.1.58
- old
+ new
@@ -8,34 +8,34 @@
before_action :build_query, only: :create
authorize_resource :query, only: :create
def index
- render json: { data: Motor::ApiQuery::BuildJson.call(@queries.active, params) }
+ render json: { data: Motor::ApiQuery::BuildJson.call(@queries.active, params, current_ability) }
end
def show
- render json: { data: Motor::ApiQuery::BuildJson.call(@query, params) }
+ render json: { data: Motor::ApiQuery::BuildJson.call(@query, params, current_ability) }
end
def create
if Motor::Queries::Persistance.name_already_exists?(@query)
render json: { errors: [{ source: 'name', detail: 'Name already exists' }] }, status: :unprocessable_entity
else
ApplicationRecord.transaction { @query.save! }
Motor::Configs::WriteToFile.call
- render json: { data: Motor::ApiQuery::BuildJson.call(@query, params) }
+ render json: { data: Motor::ApiQuery::BuildJson.call(@query, params, current_ability) }
end
rescue ActiveRecord::RecordNotUnique
retry
end
def update
Motor::Queries::Persistance.update_from_params!(@query, query_params)
Motor::Configs::WriteToFile.call
- render json: { data: Motor::ApiQuery::BuildJson.call(@query, params) }
+ render json: { data: Motor::ApiQuery::BuildJson.call(@query, params, current_ability) }
rescue Motor::Queries::Persistance::NameAlreadyExists
render json: { errors: [{ source: 'name', detail: 'Name already exists' }] }, status: :unprocessable_entity
end
def destroy