How to use image_tag method from module

A

Andrew Dangerfield

I am just getting started using ruby and rails and I have a simple class
I am refactoring with rspec and am getting the error "NoMethodError:
undefined method 'image_tag'" so I know I am doing something wrong with
bringing in the module but I do not know what and hope someone can
possibly give me some assistance. Here is the relevant code from the
class:

***********************************************************************
require 'rubygems'

class Helper

def self.foo
"foo"
end

def show(profile, size, html = {}, options = {}, link = true)
... nonrelevant code ...
return image_tag("default.png")
end
end
***********************************************************************

I have tried adding "require 'action_view/helpers/asset_tag_helper'" to
the top of the file containing the class and have tried putting "include
ActionView::Helpers::AssetTagHelper" into the body of the class but have
been unsuccessful so far. My main programming language is C/C++ where a
simple "include" would usually do the trick in a situation like this so
I am guessing that I just have not come across the documentation on the
correct way to bring in such a module.

Can anyone tell me what I am doing wrong, point me to a tutorial, or
give me a short example of the right way to use that "image_tag" method?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top