How to create and use a module?

  • Thread starter PaweÅ‚ Stawicki
  • Start date
P

Paweł Stawicki

Hi,

I am quite new to ruby and ruby on rails. I am trying to user helper
module in my controller but fail :( I added languages_helper.rb file to
helpers directory in my RoR app. The file looks like this:

module LanguagesHelper

def LanguagesHelper.sort_to_first(langs, lang)
...my secret method here...
end

end

Then I want to use it in LanguagesController. I put

require "languages_helper"

right in the beginning of the class body, and then in one of
controller's methods I try to do

ordered_langs = LanguagesHelper.sort_to_first(all_langs, lang)

When while browsing I come to this place in my browser, there is a message:

undefined method `sort_to_first' for LanguagesHelper:Module

What is wrong?

Best regards
Pawel Stawicki
 

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,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top