Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Admin::TestimonialsController < ApplicationController
- before_action :authenticate_user!
- # . . .
- def create
- testimonial = Testimonial.new(t_params)
- if testimonial.save
- testimonial = find_testimonial(testimonial.id)
- render json: testimonial, status: :created
- else
- render json: {errors: testimonial.errors}, status: :bad_request
- end
- end
- # . . .
- private
- def params_filter
- params.permit :name, :patronymic, :surname, :userpic, :company,
- :object_photo_1, :object_photo_2, :object_photo_3,
- :video, :text, :id
- end
- def t_params
- params.each { |param| param = nil if param == "null" }
- safe_params = params_filter
- params = ActionController::Parameters.new(testimonial: safe_params)
- params.require(:testimonial).permit :name, :patronymic, :surname, :userpic, :company,
- :object_photo_1, :object_photo_2, :object_photo_3,
- :video, :text, :id
- end
- # . . .
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement