views:

14

answers:

1

I'm working on a simple timesheet plugin for Redmine, all was going well until I tried to use helpers.

The helper:

module TimesheetHelper
def first_day_in_week(datum)
  return unless datum.kind_of? Date
  datum - datum.wday
end
def last_day_in_week(datum)
  return unless datum.kind_of? Date
  datum + (6 - datum.wday)
end
end

In the view I have helper "timesheet"

But I've also tried

helper :timesheet

and

helper TimesheetHelper

In the first line of index.rhtml it says

<h2><%= l :timesheet_for %> <% first_day_of_week @week %> <%=l :and %>  
<% last_day_of_week @week %></h2>

and rails throws a NoMethodError on first_day_of_week @week

Is there something I'm missing?

+1  A: 

Your method is

def first_day_in_week(datum)

not

def first_day_of_week(datum)

The name is not the same, so the method is not found ^^

marcgg
Thank you for pointing out my enormous fail. +1 for the patience
Bloodsplatter