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?
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?