You can submit the form via AJAX and get your errors without leaving the page:
http://trevorturk.com/2010/08/24/easy-a
nd-jquery/
Are you using 3.X ?
If so, you can access the errors like so:
def create
@yourmodel = Yourmodel.new(params[:yourform])
unless @yourmodel.save
respond_to do |format|
format.js {
xm = Builder::XmlMarkup
xm.ul {
@yourmodel.errors.full_messages.each do |msg|
xm.li {
xm << msg
}
end
}
render(:text=>xm)
}
format.html { flash.now[:error] = 'Error Saving'; render :action => "new" }
end
end
To make the form submit via AJAX:
form_for @yourmodel, :remote=>true , :id=>'yourform'
To get the error messages into your browser, see that this javascript is included in the view with your form:
$("#yourform").bind("ajax:success", function(event, data, status, xhr) {
$("#error_div").html(data);
});
Where error_div is a div where you display error messages.
Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.