Using the ActionView::Helpers::FormTagHelper and ActionView:


I have a utility class (in the lib/media_set/media.rb file in my ruby
application) and in there, I would like to access the
ActionView::Helpers::FormTagHelper.select_tag and
ActionView::Helpers::FormOptionsHelper.options_for_select to create a
select tag. However, in the view files, I can just refer to
select_tag(…) or options_for_select(…) and obviously rails “know”
that these are instance methods on some instance of the FormTagHelp
and FormOptionsHelper classes. I have two questions:

  1. how can I use the select_tag and options_for_select methods in my
    utility class? Can I use the same instance as would have been used in
    the view?
  2. how does Rails make accessible or associate select_tag and
    options_for_select with an existing instance of these classes in the
    view file?

Much appreciated.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs