I am trying to create a method in a controller file, and then call that method in the index.html.erb
view file.
Here are both my index action and my custom method in the controller file:
def index
@mustdos = current_user.mustdos
end
def calculates_mustdos_days_left
((mustdo.created_at + 7.days - Time.now) / ( 60 * 60 * 24)).round
end
helper_method :calculates_mustdos_days_left
And here is the relevant code from my associated my index.html.erb
file:
<% @mustdos.each do |mustdo| %>
<tr id="todo-<%= "#{mustdo.id}" %>">
<td><%= calculates_mustdos_days_left %></td>
</tr>
<% end %>
I am getting this error:
NameError in Mustdos#index
And it is referencing this line from my index.html.erb
view file
<td><%= calculates_mustdos_days_left %></td>
How can I resolve this? Thanks.