Reputation: 103863
I would like to have Ajax form in Rails so i'm using form_remote_tag. The field i would like to submit is email address - how can i use the Rails validations together with form_remote_tag?
Upvotes: 0
Views: 1486
Reputation: 1630
We're using form_remote_tag with the :update option and paste the whole form into a partial. Once the form is submitted and validation fails, the partial is being rendered again and all error messages will show up.
This is the workflow:
Upvotes: 3
Reputation: 1805
In your form processing controller action decide whether
You can (should) make this decision based on validations
def create
m = Model.new(params)
if m.valid?
m.save
#load flash with succes message
else
#load flash with error messages from m.errors
#render the form again
end
end
Upvotes: 1