Creating a gem with init.rb Rails 3

I created a new stone: https://github.com/tntwebsolutions/ts3query

In my init.rb file, I am the requiremain lib file, this should automatically load the gem when loading the rails application. But when I start the server, it comes in that the file is init.rbnot loading.

In my application, I have this in my Gemfile:

gem "ts3query", "~> 0.2.1"

And do it in mine application_controller.rb:

@query = TS3Query.connect :password => password

But then I get this error:

uninitialized constant ApplicationController::TS3Query

If I do this:

require 'TS3Query'
@query = TS3Query.connect :password => password

It works. But I can’t understand what I need to change on my stone in order to load require 'TS3Query'when the rails application is loaded.

+3
source share
2 answers

init.rb , TS3Query.rb ts3query.rb, .

, Linux Mac , , , -, , .

+5

- , TS3Query.rb lib. , , , ts3query.rb. :

  • ts3query.rb
  • ts3query.rb "TS3Query"
  • Gemfile gem "ts3query", "~> 0.2.1", :require => "TS3Query".
+1

All Articles