What is the easiest way to make a group of methods available to multiple Rails applications

TL; DR

In what simple way can I create a view help module that I can use in many applications?

What file, where is it downloaded, how?

I'm on Rails 2.3.11.


I have a bunch of helper presentation methods. Here is an example of one of them:

  # Render form input fields to add or edit a ZIP code.
  def render_zip_code_fields( model_instance )
    # Bla bla bla ...
  end

I have about 20 or so that I have developed over the years and often use in various applications. I would like to combine all of them into one file, which I can simply insert into the application, and then I will be able to name them in my representations.

Why not just copy and paste them into application_helper.rb? I just don't like it. It seems to be a separate file.

Actually I tried to create in /lib...

# /lib/my_view_helpers.rb

module MyViewHelpers

  # ...

end

application_helper.rb ...

include MyViewHelpers

" MyViewHelpers. , ? , require my_view_helpers.rb, /lib. ,

, ?

, . , .

+3
1

Rails 3, /lib . Application config/application.rb.

config.autoload_paths += ["#{config.root}/lib"]

app/helpers, .

+1

All Articles