What is the correct way to load a module from lib/?
I have a Tournament model, which represents a tournament (I assume most people are familiar with what a tournament is). I want my tournaments to be accessed the same way, using RESTful routes, but I also wish to allow tournaments of multiple formats. Since there is a considerable amount of logic involved in generating a tournament in a particular format, I want a way to separate the format logic, and store that logic in a module. This is my setup:

In lib/formats/ I have single_elimination.rb:

    module SingleElimination
      def test
        "Hello"
      end
    end

I then modified my application configuration to add:

    config.autoload_paths += %W(#{config.root}/lib/formats/)

Finally, I added this to my Tournament model:

    class Tournament < ActiveRecord::Base
      include SingleElimination
      # ...
    end

However, I get this error: `uninitialized constant Tournament::SingleElimination`

What can I do to resolve this problem?


What is the correct way to load a module from lib/?
===

I have a Tournament model, which represents a tournament (I assume most people are familiar with what a tournament is). I want my tournaments to be accessed the same way, using RESTful routes, but I also wish to allow tournaments of multiple formats. Since there is a considerable amount of logic involved in generating a tournament in a particular format, I want a way to separate the format logic, and store that logic in a module. This is my setup:

In lib/formats/ I have single_elimination.rb:

    module SingleElimination
      def test
        "Hello"
      end
    end

I then modified my application configuration to add:

    config.autoload_paths += %W(#{config.root}/lib/formats/)

Finally, I added this to my Tournament model:

    class Tournament < ActiveRecord::Base
      include SingleElimination
      # ...
    end

However, I get this error: `uninitialized constant Tournament::SingleElimination`

What can I do to resolve this problem?

