app/controllers/motor/forms_controller.rb in motor-admin-0.1.57 vs app/controllers/motor/forms_controller.rb in motor-admin-0.1.58

- old
+ new

@@ -8,34 +8,34 @@ before_action :build_form, only: :create authorize_resource :form, only: :create def index - render json: { data: Motor::ApiQuery::BuildJson.call(@forms.active, params) } + render json: { data: Motor::ApiQuery::BuildJson.call(@forms.active, params, current_ability) } end def show - render json: { data: Motor::ApiQuery::BuildJson.call(@form, params) } + render json: { data: Motor::ApiQuery::BuildJson.call(@form, params, current_ability) } end def create if Motor::Forms::Persistance.name_already_exists?(@form) render json: { errors: [{ source: 'name', detail: 'Name already exists' }] }, status: :unprocessable_entity else ApplicationRecord.transaction { @form.save! } Motor::Configs::WriteToFile.call - render json: { data: Motor::ApiQuery::BuildJson.call(@form, params) } + render json: { data: Motor::ApiQuery::BuildJson.call(@form, params, current_ability) } end rescue ActiveRecord::RecordNotUnique retry end def update Motor::Forms::Persistance.update_from_params!(@form, form_params) Motor::Configs::WriteToFile.call - render json: { data: Motor::ApiQuery::BuildJson.call(@form, params) } + render json: { data: Motor::ApiQuery::BuildJson.call(@form, params, current_ability) } rescue Motor::Forms::Persistance::NameAlreadyExists render json: { errors: [{ source: 'name', detail: 'Name already exists' }] }, status: :unprocessable_entity end def destroy