In the past I struggled with having a consistent strategy for showing error messages in javascript. In rails we usually put the error/success messages in the flash, However if the request is an ajax request the flash doesn’t get used and the message shows up on the next page load.
The following code shows error/success messages using the flash properly
1 | #app/classes/ajax_flash.rb |
Include this javascript code
1 | (function(){ |
To use this you just need to use your normal code with respond_to
1 | def create |
I am currently working on LiveForm which makes
setting up contact forms on your website a breeze.