ActiveRecord validation with ajax calls

Hi   I have a model class ServiceDeskResolution.It has fields, code and solution.I have to make the solution not empty .So for that I wrote validates_presence_of :resolution in the model.So from the view when I click save nothing is saved to database.This is what I need.But no error messages are printed and the view goes to next window..How can I print error messages in the current window?

View code (define_sd_resolution.rhtml) <%= error_messages_for 'service_desk_resolution' %> #This not working

I have good suggestion if you spend 5 minutes to Examples - Live Validation, and download their script :D. I hope it will help you.

I am not sure your code here, maybe it should be :

def sd_resolution_save

@service_desk_resolution=ServiceDeskResolution.new(params[:sd_resolution])   if @service_desk_resolution.save      render :action => "sd_resolution_save.rjs"   else      render :action => 'define_sd_resolution'      #render :file => "#{RAILS_ROOT}/public/define_sd_resolution.rhtml"      # I am not sure with render file.   end end

your code before dont have block to break error, so it will execute :action => "sd_resolution_save.rjs" although it is error or failed validation.

Good Luck, http://Teapoci.Blogspot.com Reinhart