Ruby on rails 未定义的方法“时间的距离”(大写)';
关于未定义的方法“单词中时间的距离”,我有两个问题 在我看来,我正在尝试此方法,并获得未定义的方法:Ruby on rails 未定义的方法“时间的距离”(大写)';,ruby-on-rails,Ruby On Rails,关于未定义的方法“单词中时间的距离”,我有两个问题 在我看来,我正在尝试此方法,并获得未定义的方法: <td><%= distance_of_time_in_words (patient_course_step.started, patient_course_step.completed) %></td> 在我看来,我怎样才能用文字表达时间的距离 在模型中使用helper方法(如上所示)是一种好的实践吗 这样做不是一种好的做法,但我理解这样做的必要性。请参见
<td><%= distance_of_time_in_words (patient_course_step.started, patient_course_step.completed) %></td>
这样做不是一种好的做法,但我理解这样做的必要性。请参见如何操作。尝试使用
您的\u对象\u名称。距离
。它应该可以工作感谢链接,这应该可以解决我的模型问题,但是为什么助手不能从视图工作呢?我是否需要将其包含在配置文件中的某个位置?我从模型中获得了它,但从视图中看不到它。我真的不需要它在那里工作,但有趣的是它不工作,它怎么不工作?在模型中调用助手,在视图中调用它?它在说什么?
def duration
distance_of_time_in_words (self.started, self.completed)
end
def status
if started.nil?
created_at_formated = created_at.strftime("%B %d, %Y, %l:%M %p")
return "Not started assigned on #{created_at_formated}"
elsif !completed.nil?
completed_formated = completed.strftime("%B %d, %Y, %l:%M %p")
return "Completed at #{completed_formated}"
else
last_viewed_formated = last_viewed.strftime("%B %d, %Y, %l:%M %p")
return "In Progress, last viewed at #{last_viewed_formated}"
end
end