0

I have the following code in my show view.

<p>
  <strong>Average difference:</strong>
  <%= @prediction.average_difference %>
</p>

However, the field's value is not printed. What am I doing wrong?

2 Answers 2

1

Probably @average_difference attribute of @prediction is nil. In order to confirm that, you may write

<%= @prediction.average_difference || 'test_average_difference' %>

which should display test_average_difference.

Sign up to request clarification or add additional context in comments.

Comments

1

Fire up rails console to check @prediction.average_difference if it shows up a value their in console it must show the same in the view as well.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.