Forum: Ruby on Rails mixing in action view helper methods in a class

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
42d4590355a1404230fbc9aff4dd377b?d=identicon&s=25 Myron Marston (Guest)
on 2007-05-13 09:01
(Received via mailing list)
I've got a class where I would like to use the TextHelper truncate
method.  It's not a M, V or C but is called by a controller.  I
figured I should be able to mixin the TextHelper in order to have
access to the truncate method.  But I can't get it to work.  I'm new
to Ruby and ROR, so I haven't done mixins before.

Here's what I've got...

class Searcher
  require 'action_view/helpers/text_helper'
  include ActionView::Helpers::TextHelper

I get a NoMethodError: undefined method `truncate' for
Searcher:Class.  How do I get this to work?

By the way, I apologize if this has already been answered in this
group (as is likely), but I did a search and couldn't find it.

This topic is locked and can not be replied to.