How to create and use a module?

Discussion in 'Ruby' started by Paweł Stawicki, Aug 7, 2007.

  1. 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
     
    Paweł Stawicki, Aug 7, 2007
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel Ortmann
    Replies:
    4
    Views:
    794
    Skip Montanaro
    Jul 2, 2003
  2. Maric Michaud
    Replies:
    0
    Views:
    7,332
    Maric Michaud
    Jun 24, 2006
  3. -ecosys.com
    Replies:
    4
    Views:
    484
    Calvin Spealman
    Sep 28, 2007
  4. Krithika San
    Replies:
    3
    Views:
    561
    Marnen Laibow-Koser
    Nov 14, 2009
  5. Replies:
    4
    Views:
    328
    Uri Guttman
    Jan 31, 2006
  6. kellinorman
    Replies:
    7
    Views:
    198
    Bart Lateur
    Apr 19, 2006
  7. David Filmer
    Replies:
    2
    Views:
    389
    C.DeRykus
    Mar 29, 2013
  8. Sam
    Replies:
    7
    Views:
    249
    Marcel Rodrigues
    Feb 9, 2014
Loading...