1

I am using Grape GEM in my rails app, How can I customize response if record not found or request params are in valid

@video = Video.where(id: permitted_params[:id]).first!

for example there is no record for any id

Vipin
  • 111
  • 1
  • 10

1 Answers1

3

You can do like this:

@video = Video.where(id: permitted_params[:id]).first!
if @video
   #your code
else
  error!({:error_message => "Record Could not found"}, 422)
end
Gaurav Gupta
  • 1,181
  • 10
  • 15