Q:

Where and how should I add this new 'non-rails-way' method in my Rails application

I've written a small method to query and retrieve from an MS SQL 2008 server and I am not sure where to put the code in my rails app.
The scenario:
I am writing a Ruby and Rails app with a connection to a legacy MS SQL 2008 server DB.
A lot is working as expected, which is nice.
For now I work off a copy of the legacy DB and I treat it as readonly.  It's big (7000+ tables some of which have over 40 million records).  I am using it 'as-is' and don't want to change any of the underlying schema.
I do want to extend some very server-specific functionality.  For instance, I make use of:
thing = ActiveRecord::Base.connection.exec_query(my_query_string_here)

... and it works.  The result is an array that contains a hash and I can get to the relevant hash value by using:
thing[0][""]

... which works. 
So, I thought I should write a method to make this easier and I wrote:
Class Tool < ActiveRecord::Base
  def self.queryRDW(x)
    res=ActiveRecord::Base.connection.exec_query(x)
    ret=res.to_hash
    return ret[0][""]
  end
end 

and put it in config/initializers/tool.rb  Unfortunately, webrick complains about the file during boot with the following cryptic error:
.../config/initializers/tool.rb:7: syntax error, unexpected keyword_end, expecting $end (SyntaxError)

I recognize that this is not an out-of-the-box rails-way of doing things, so please don't remind me.  (My struggles remind me often enough)
My question:
Where should I put this code so that I can invoke it from within a controller or a view in my rails app?  Does this need to be a new Class method or something else?
Many thanks!
Addendum:
I changed Class to class (doh!)
I moved tool.rb into lib/
I changed tool.rb to now be:  
module Tool
  def self.queryRDW(x)
    res = ActiveRecord::Base.connection.exec_query(x)
    res.to_hash[0][""]
  end
end

but doing this in app/views/stats.html.erb
thing=queryRDW("mysql string")

gets me an 'undefined method error'
Addendum 2
I made the directory app/concerns and put tool.rb there.
When I use:  
<%=queryRDW("myStringHere")%>

in:
app/views/stats.html.erb

I get:
undefined method `queryRDW' for #<#<Class:0x0000000378ccf8>:0x00000003c1ce58>  

A:

You need to lowercase the keyword class in line 1.
I'd also say that this class doesn't need to inherit from ActiveRecord::Base — and doesn't even really need to be a class — if it's simply a wrapper around exec_query. There's nothing "wrong" with this, but if you never intend to instantiate an object of this class, you could just create a simple utility module:
module Tool
  def self.queryRDW(x)
    res = ActiveRecord::Base.connection.exec_query(x)
    res.to_hash[0][""]
  end
end

You can save this file in a couple of places:

lib/tool.rb. If you're using Rails 3, you'll need to add (or uncomment) this line in config/application.rb:
# config/application.rb
config.autoload_paths += %W(#{config.root}/lib)

app/concerns/tool.rb. This will automatically be detected by Rails 3.

I generally use app/concerns for tools that are entirely application-specific and lib for utilities that I might reuse among several different applications.

