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 = "<tr><td valign=\"top\"><label for=\"#{obj_name}_#{field_name}\">" text += "</label></td>\n" if obj[field_name].nil? or DateTime.now < obj[field_name] text += "<td>" text += date_select obj_name, field_name text += "</td></tr>\n" else text += "<td><p>#{obj[field_name]}</p></td></tr>\n" 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. -- Posted via http://www.ruby-forum.com/.
Answering my own question, I just removed the "helper :date_helper" and "include DateHelper" lines and it worked. I confused myself because in earlier version, I had mistakenly wrapped the "date_select" statement in "<%= .. %>" tags, thinking it would be re-evaluated. When it wasn''t, I initially assumed that DateHelper wasn''t being pulled in. When I figured out that that wasn''t the issue, I forgot to remove the added lines. Sorry for the noise (but maybe it will help someone else down the line). -- Posted via http://www.ruby-forum.com/.
It''s always appreciated when you post an answer to a problem, even if it is your own question :) Charlie bowman www.recentrambles.com On Wed, 2006-05-03 at 20:53 +0200, Coey Minear wrote:> Answering my own question, I just removed the "helper :date_helper" and > "include DateHelper" lines and it worked. I confused myself because in > earlier version, I had mistakenly wrapped the "date_select" statement in > "<%= .. %>" tags, thinking it would be re-evaluated. When it wasn''t, I > initially assumed that DateHelper wasn''t being pulled in. When I > figured out that that wasn''t the issue, I forgot to remove the added > lines. > > Sorry for the noise (but maybe it will help someone else down the line). >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060503/08f3bb75/attachment-0001.html
Reasonably Related Threads
- Overriding date_select in local project to use custom value rather than blank for starting option...
- Problem with date_select after Rails 2.1 upgrade
- select_datetime // datetime_select
- Rails 2.1 and ddatetime_select
- date_helper megapatch and MultiparameterAssignmentErrors