Is there an easier way to make something display only in the non-error state? (Ruby on Rails) -


I have some text / images which I want to show only in the general state of a form - that is, it is not submitted However, even if the user has submitted the form, and it has returned to the browser with errors, then I want to show something else. Currently, I'm using:

  & lt;% if !@user.errors.empty? -% & gt; # Leave this field blank & lt;% else -% & gt; # Inserting something here & lt;% end -% & gt;  

But it should feel a bit heavy and be a simple way.

It's really easy to do, but I do not know anything about it - though, I'm probably not asking the question right.

Thanks for the help!

I just can not imagine something completely different But do not you just use the if statement, when you only need one branch of it?

  & lt;% if @ users.errors.empty? & Gt%; #include something here & lt;% end% & gt;  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -