<p>I'm trying to verify that a parameter is an instance of a specific class in Rails:</p>

<pre><code>def schedule(action, *args)
  if arg.is_a? Aircraft
    ...
  end
end
</code></pre>

<p>I'm doing this in a library class (the file is in <em>lib/</em>) and I get an <strong>uninitialized constant Aircraft</strong> error. Aircraft is a model class, with a corresponding <em>aircraft.rb</em> file in <em>app/models</em>.</p>

<p>Can I use model classes and instances in a library? How?</p>

<hr>

<p><strong>Error context:</strong></p>

<p>The error happens in RSpec tests; the code works in the browser. I tried requiring the model in the <em>_spec.rb</em> file, no success at the moment.</p>

This will give you access to the Aircraft model:
```
```
require File.dirname(__FILE__) + "/../app/models/aircraft"
```
```
[edit]
Daniel brings up a good point about the context. If you're using a rake task make sure you load the environment:
```
```
task :my_task => :environment do
  # something happens...
end
```
```