0

i send an form remotely and wanted to add a validation to it. this is in my model:

  validates :email, :presence => true, :email => true

validation works fine, when email is valid it adds it to the database, if not, then not. my problem is, whenever i submit the form, it renders my subscribe.js file:

$('.form').html("<p><strong>Thank you for your interest!<br />We'll keep you up-to-date.</strong></p>"); 

how can i tell rails, that if the email adress is unvalid, it should render another .js file? or is there another way?

thank you!

1 Answer 1

1

Maybe something like this...

if @object.save 
  respond_to do |format|
    format.js
  end
else   
  render # something else
end
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.