ActiveRecord validation with ajax calls

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


<%= submit_to_remote ‘save_btn’, ‘Save’,
:html => {:class => “itilbutton1”},
:url => {:controller => ‘service_desk’, :action =>
‘sd_resolution_save’, :id =>, :sd_resolution_id =>
@sd_resolution_id}, :before =>
‘Please Choose Resolution’);” %>

controller code
def sd_resolution_save[:sd_resolution])
render :action => “sd_resolution_save.rjs”


what I need is if ! how can i revert
this back to the same define_sd_resolution.rhtml and print the
validation message on that.
Thanks in advance

I have good suggestion if you spend 5 minutes to, 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[:sd_resolution])
render :action => “sd_resolution_save.rjs”
render :action => ‘define_sd_resolution’
#render :file => “#{RAILS_ROOT}/public/define_sd_resolution.rhtml”
# I am not sure with render file.

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

Good Luck,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs