handle required

This commit is contained in:
bijan 2023-05-01 16:40:25 +03:30
parent 2258a13598
commit 02aafa70fd

View File

@ -3,7 +3,7 @@ class MessagesController < ApplicationController
def create
if params[:title].length > 300 || params[:name].length > 50 || params[:description].length > 1000
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)