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
Post a Comment