Putting a calculation method in the model

Do I need to define @duration somewhere? I want to calculate the
duration of a call in the model and then for the view to display that
calculation.

Right now, the view, show.rhtml for calls, is giving an “You have a nil
object when you didn’t expect it!” error :frowning:

[email protected] ~/goodfellow-tool $
[email protected] ~/goodfellow-tool $ cat app/views/calls/show.rhtml -n |
head -n 9 | tail -n 1
9

The call duration was <%= @call.duration.to_s %> long.


[email protected] ~/goodfellow-tool $
[email protected] ~/goodfellow-tool $ cat app/models/call.rb
class Call < ActiveRecord::Base

def duration
return (@end - @start).to_time
end

end
[email protected] ~/goodfellow-tool $

the trunk where the code is at:
http://code.google.com/p/goodfellow-tool/source/browse

thanks,

Thufir

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs