I am trying to push some view logic into a helper. The thought is that
this is a step towards having the business logic in the helper rather
than the view. However, I’m essentially wrapping the checks around an
eventual call to date_select(). The problem I’m having is that the
application complains that it doesn’t know about date_select(). I’m
sure (or hope) it’s simple, but so far, I haven’t issued the right
commands.
To give an example of what I’m doing:
from the view:
<%= format_planned_start_date @plan, 'plan', 'planned_to_start_on',
‘Planned Start Date’ %>
and from my helper:
require ‘date’
module HtmlHelper
helper :date_helper
include DateHelper
def format_planned_start_date(obj, obj_name, field_name, label)
text = “
for=”#{obj_name}_#{field_name}">"
text += “\n”
if obj[field_name].nil? or DateTime.now < obj[field_name]
text += “
text += date_select obj_name, field_name
text += “
else
text += “
#{obj[field_name]}
end
text
end
end
The above gives the error: undefined method `helper’ for
HtmlHelper:Module
I’ve also tried “require ‘date_helper’” at the top and without the
“helper :date_helper” without success.
I’ll still poke at this, but I’m not seeing the obvious solution.