I changed my form to remote, and while the form now works, the error messages are no longer displaying if there's an error.
<%= render 'shared/error_messages' %>
is there a good wear to get the messages to show again?
below is my controller...
thank you.
respond_to do |format|
if @post.save
format.js { render :js => "window.location = '#{edit_post_path @post}'" }
format.html { redirect_to [:edit, @post] }
else
format.js { render :js => @post.errors }
format.html { redirect_to '/', :error => "Could not save comment" }
end
end
respond_to do |format|
if @post.save
format.js { render :js => "window.location = '#{edit_post_path @post}'" }
format.html { redirect_to [:edit, @post] }
else
format.js { }
format.html { redirect_to '/', :error => "Could not save comment" }
end
end
# update.js.erb
$(document).find("form").prepend('<%= escape_javascript(render("shared/error_messages", :formats => [:html])) %>');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With