tomekfranek
tomekfranek

Reputation: 7109

How to send instance variables when rendering a partial

I want to render action if my model is not valid.

render "book_page"

https://gist.github.com/f7259eb79d1f2c951036

But for now @prices_per_night and @number_of_nights are nil when i click submit button. How to prevent this?

I tried to move this form to partial but it now happend, because I cant render only partial. Or Am I wrong?

Upvotes: 0

Views: 493

Answers (1)

oseiskar
oseiskar

Reputation: 3372

Using render does not make Rails call the relevant method, book_page, in the controller. It proceeds directly to book_page.html.erb and, at this point, no method has set your instance variables so they appear nil.

Upvotes: 1

Related Questions