contactUs/app/controllers/messages_controller.rb
2023-05-01 16:40:25 +03:30

19 lines
555 B
Ruby

class MessagesController < ApplicationController
skip_before_action :verify_authenticity_token
def create
if (params[:title].try(:length) || 10) > 300 || (params[:name].try(:length) || 100) > 50 || (params[:description].try(:length) || 10) > 1000 || (params[:email].try(:length) || 0) < 1
render json: {}, status: 400
else
@message = Message.create(message_params)
render json: {}, status: :created
end
end
private
def message_params
params.permit(:title, :phone, :description, :email, :name)
end
end