ruby - Rails 4: How to check validation errors from inside a controller -


i have basic model validations triggered when form gets submitted ajax. if validations fail, want pass validation errors view can tell user.

  def save     logger.debug( params )     @video = video.new( video_params )     if @video.save         render json: @video     else         render json: errors.messages     end   end 

this throws error because errors undefined. doing wrong? read the docs on this , shows errors.messages used in view.

errors instance method activerecord. correct way use in case this:

@video.errors.messages 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -