# Expected ... to define

**URL:** <https://www.ruby-forum.com/t/expected-to-define/108499>\
**Category:** Rails\
**Created:** [July 4, 2007, 5:24am UTC](https://www.ruby-forum.com/t/expected-to-define/108499 "2007-07-04T05:24:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![terhorst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9e5f3/32.png) [@terhorst](https://www.ruby-forum.com/u/terhorst)\
**Post date:** [July 4, 2007, 5:24am UTC](https://www.ruby-forum.com/t/expected-to-define/108499/1 "2007-07-04T05:24:33Z")

</div>

I found several topics that covered a similar error with controllers,  
but mine is with a model, and none of the fixes previously mentioned  
seemed to apply.

Here is the error:

Expected ./app/models/lab\_result.rb to define Lab\_result

C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active\_support/dependencies.rb:249:in  
`load_missing_constant' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:452:in`const\_missing’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active\_support/dependencies.rb:464:in  
`const_missing' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:260:in`load\_missing\_constant’  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active\_support/dependencies.rb:468:in  
`const_missing' #{RAILS_ROOT}/app/controllers/visit_controller.rb:72:in`delete\_lab’

Here is the method causing causing the error:

def delete\_lab  
@lab\_result = Lab\_result.find(params[:id])  
if @lab\_result.destroy  
flash[:notice] = “Lab results successfully deleted”  
redirect\_to :action =\> ‘update’, :id =\> @lab\_result.visit  
end  
end

Here is the Lab\_result model sitting comfortably in the models dir:

class LabResult \< ActiveRecord::Base  
belongs\_to :lab  
belongs\_to :visit  
end

Any advice?

---

<div class="post-metadata">

**Author:** ![terhorst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9e5f3/32.png) [@terhorst](https://www.ruby-forum.com/u/terhorst)\
**Post date:** [July 4, 2007, 5:40am UTC](https://www.ruby-forum.com/t/expected-to-define/108499/2 "2007-07-04T05:40:08Z")

</div>

Hi Jonathan,

Jonathan Towell wrote:

> Here is the error:
> 
> Expected ./app/models/lab\_result.rb to define Lab\_result

> `const_missing' #{RAILS_ROOT}/app/controllers/visit_controller.rb:72:in`delete\_lab’
> 
> Here is the method causing causing the error:
> 
> def delete\_lab  
> @lab\_result = Lab\_result.find(params[:id])

> Here is the Lab\_result model sitting comfortably in the models dir:
> 
> class LabResult \< ActiveRecord::Base

The find occurs on the model. You’re using some sort of combination of  
the  
model class and the model class file name. Try:

@lab\_result = LabResult.find(params[:id])

hth,  
Bill
