All threads / Render :new form is blank
Ask A Question


You’re not receiving notifications from this thread.

Render :new form is blank

Amanda asked in Rails

In my create method I have the following:

respond_to do |format|
format.html { redirect_to admin_purchase_agreements_path, notice: 'Purchase agreement was successfully created and is pending approval by the Loan Originator' }
format.json { render :show, status: :created, location: @purchase_agreement }
format.html { render :new }
format.json { render json: @purchase_agreement.errors, status: :unprocessable_entity }

I have these validations in my model:

validates :buyer_email, presence: true, if: :electronic_signature?

electronic_signature is a boolean. I am checking to see that if they want to use an electronic_signature that there is a buyer_email.

The problem I am having is that when there isn't a buyer_email and it fails the validation, it is rendering the form, however, the form is blank. When I debug it, I can see that my @purchase_agreement has all the original values set from when trying to save it, as do the params but nothing is displayed on the form.

I am at a loss as to where I have gone wrong.


Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 66,029+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.