I have a model class SDResolution.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?

Thanks in advance

that’s a question of your controller logic.

do it something like that:

def update
@sdresolution = SDResolution.find(params[:id]
if @sdresolution.update_attributes(params[:sdresolution]) then
…render next view—
redirect_to edit action (or just render edit view again)

in your view (for edit) just add
<%= error_messages_for(:SDResolution) %>
this will display error messages if there are any on the @sdresolution

had a very short look at it (sorry, have some work to do)

but it seems in your action you do:
@[email protected]_ticket_resolution.update_attributes(params[:sd_resolution])

using @sd_ticket_resolution

while your view uses:
<%= error_messages_for ‘service_desk_resolution’ %>

this should be
<%= error_messages_for ‘sd_ticket_resolution’ %>

to render the errors that may be on @sd_ticket_resolution
after the update_attributes

I am using ajax submit to remote here…I could succeed this
validation on another place without ajax…I am attaching the code for
this .Could you please go through it and make a suggestion?


Thanks for your reply…Stil have problem .Could you please look at the
code when get time?

Thanks in advance

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