# NameError in CompetitorsController#index

**URL:** <https://www.ruby-forum.com/t/nameerror-in-competitorscontroller-index/188640>\
**Category:** Rails\
**Created:** [May 15, 2010, 9:28am UTC](https://www.ruby-forum.com/t/nameerror-in-competitorscontroller-index/188640 "2010-05-15T09:28:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![manish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@manish](https://www.ruby-forum.com/u/manish)\
**Post date:** [May 15, 2010, 9:28am UTC](https://www.ruby-forum.com/t/nameerror-in-competitorscontroller-index/188640/1 "2010-05-15T09:28:44Z")

</div>

Hi all

I am getting this problem when I run this code in server. In my  
localhost everything is running fine. But when I deploy my code in the  
server it shows me the error. I am using FERRET SERARCH IN MODEL.

NameError in CompetitorsController#index

uninitialized constant CompetitorsController::Competitor

RAILS\_ROOT: /home/troche/mrecip\_tool/releases/20091219131859  
Application Trace | Framework Trace | Full Trace

/opt/ruby\_enterprise/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active\_support/dependencies.rb:102:in  
`const_missing' /home/troche/mrecip_tool/releases/20091219131859/app/controllers/competitors_controller.rb:19:in`index’

My controller is

class CompetitorsController \< ApplicationController

include AuthenticatedSystem  
layout ‘application’

auto\_complete\_for :proscribed, :competitor  
auto\_complete\_for :fee\_earner, :fee\_earner

protect\_from\_forgery :only =\> [:tag]

before\_filter :login\_required, :only =\> [:index, :show, :new, :edit]

@@total\_company = 70

# GET /competitors

# GET /competitors.xml

def index  
@compet = Competitor.find(:all) ### GETTING ERROR IN THIS LINE

```
respond_to do |format|
  format.html # index.html.erb
  format.xml { render :xml => @compet }
end

```

end

# GET /competitors/1

# GET /competitors/1.xml

def show  
@competitor = Competitor.find(params[:id])

```
respond_to do |format|
  format.html # show.html.erb
  format.xml { render :xml => @competitor }
end

```

end

# GET /competitors/new

# GET /competitors/new.xml

end

* * *

My Model is

class Competitor \< ActiveRecord::Base

validates\_presence\_of :fee\_earner\_id, :notes

belongs\_to :fee\_earner  
belongs\_to :country  
belongs\_to :state  
belongs\_to :user

acts\_as\_ferret :fields =\>[:competitor, :client, :subject\_matter],:remote  
=\> true

end

---

<div class="post-metadata">

**Author:** ![manish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@manish](https://www.ruby-forum.com/u/manish)\
**Post date:** [May 15, 2010, 4:58pm UTC](https://www.ruby-forum.com/t/nameerror-in-competitorscontroller-index/188640/2 "2010-05-15T16:58:06Z")

</div>

On Sat, May 15, 2010 at 12:28 AM, Manish N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I am getting this problem when I run this code in server. In my  
> localhost everything is running fine. But when I deploy my code in the  
> server it shows me the error.

> def index  
> @compet = Competitor.find(:all) ### GETTING ERROR IN THIS LINE

Are you sure all your migrations have run successfully on the server?  
What happens if you open a console and try `Competitor.find(:all)` ?

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![manish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@manish](https://www.ruby-forum.com/u/manish)\
**Post date:** [May 15, 2010, 5:00pm UTC](https://www.ruby-forum.com/t/nameerror-in-competitorscontroller-index/188640/3 "2010-05-15T17:00:26Z")

</div>

On May 15, 9:28 am, Manish N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> class Competitor \< ActiveRecord::Base

Is this in app/models/competitor.rb (case is probably important) ?

Fred

---

<div class="post-metadata">

**Author:** ![manish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@manish](https://www.ruby-forum.com/u/manish)\
**Post date:** [May 18, 2010, 10:16am UTC](https://www.ruby-forum.com/t/nameerror-in-competitorscontroller-index/188640/4 "2010-05-18T10:16:31Z")

</div>

Frederick C. wrote:

> On May 15, 9:28ï¿½am, Manish N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > class Competitor \< ActiveRecord::Base
> 
> Is this in app/models/competitor.rb (case is probably important) ?
> 
> Fred

Yes it in the app/models/competitor.rb

---

<div class="post-metadata">

**Author:** ![manish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@manish](https://www.ruby-forum.com/u/manish)\
**Post date:** [May 18, 2010, 10:17am UTC](https://www.ruby-forum.com/t/nameerror-in-competitorscontroller-index/188640/5 "2010-05-18T10:17:27Z")

</div>

Hassan S. wrote:

> On Sat, May 15, 2010 at 12:28 AM, Manish N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > I am getting this problem when I run this code in server. In my  
> > localhost everything is running fine. But when I deploy my code in the  
> > server it shows me the error.
> 
> > ï¿½def index  
> > ï¿½ ï¿½@compet = Competitor.find(:all) ï¿½ ### GETTING ERROR IN THIS LINE
> 
> Are you sure all your migrations have run successfully on the server?  
> What happens if you open a console and try `Competitor.find(:all)` ?
> 
> –  
> Hassan S. ------------------------ removed\_email\_address@domain.invalid  
> twitter: @hassan

Yes Hassan all my migrations have run successfully on the server.  
On the server there is no console facility.

---

<div class="post-metadata">

**Author:** ![manish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@manish](https://www.ruby-forum.com/u/manish)\
**Post date:** [May 18, 2010, 10:27am UTC](https://www.ruby-forum.com/t/nameerror-in-competitorscontroller-index/188640/6 "2010-05-18T10:27:53Z")

</div>

On 15 May 2010 08:28, Manish N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> RAILS\_ROOT: /home/troche/mrecip\_tool/releases/20091219131859  
> class CompetitorsController \< ApplicationController
> 
> @@total\_company = 70
> 
> # GET /competitors
> 
> # GET /competitors.xml
> 
> def index  
> @compet = Competitor.find(:all) ### GETTING ERROR IN THIS LINE

Have you checked that there is a competitors table in the production  
database (perhaps you forgot to run the migrations on that db as  
Hassan suggested)?  
Also check that the file app/models/competitors.rb is present on the  
production server and restart the server.  
You have not answered Hassan’s question:  
What happens if you open a console and try `Competitor.find(:all)` ?  
(on the production server)

Colin
