I know this should be easy, but can't really find a straight answer on how im supposed to be calling a method from html.erb.
On my edit page, I want to run a simple time calculation (current time - start time from DB).
I trying to call the method using
Time: <% totalhours(@timetracker.time_start, @time_now) %>
In my timetracker contoller edit action I have
def edit
def totalhours(starttime, endtime)
totalhourscalc = (Time.parse(endtime) - Time.parse(starttime) / 3600)
p totalhourscalc
end
end
'''
The error im getting is "undefined method `totalhours' for #<ActionView::Base:0x007f244820cc90> {highlighted} Time: <% totalhours(@timetracker.time_start, @time_now) %>" {/highlighted}
I have tried multuple variations and spent last couple of hours trying to find a simple answer. Help would be greatly appreciated on what im doing wrong.
Thank you in advance!!!!!!!