# Uninitialized constant

**URL:** <https://www.ruby-forum.com/t/uninitialized-constant/134658>\
**Category:** Rails\
**Created:** [April 13, 2008, 4:35pm UTC](https://www.ruby-forum.com/t/uninitialized-constant/134658 "2008-04-13T16:35:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lfeistel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecc23a/32.png) [@lfeistel](https://www.ruby-forum.com/u/lfeistel)\
**Post date:** [April 13, 2008, 4:35pm UTC](https://www.ruby-forum.com/t/uninitialized-constant/134658/1 "2008-04-13T16:35:07Z")

</div>

Hi guys, I’m part way through a RoR application, for some reason  
whenever I add new controllers (using scaffold) I get an uninitialized  
constant [name of controller] error.

The first few controllers work fine, the only thing I can see that I’ve  
changed is the layout file (but scaffold creates a new layout for each  
controller so can’t see that being the problem). You can all probably  
tell I’m new to rails so hoping this is some newb error…

the failing controllers can be found at  
[http://spotter.derbyproject.com/exercises/list](http://spotter.derbyproject.com/exercises/list)  
[http://spotter.derbyproject.com/updates/](http://spotter.derbyproject.com/updates/)

and working ones are here  
[http://spotter.derbyproject.com/users](http://spotter.derbyproject.com/users)

Just for clarity, Ive been adding controllers as I go, but the last two  
added have given this error straight after running scaffold (I haven’t  
made any changes to them).

thanks!

---

<div class="post-metadata">

**Author:** ![lfeistel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecc23a/32.png) [@lfeistel](https://www.ruby-forum.com/u/lfeistel)\
**Post date:** [April 13, 2008, 4:47pm UTC](https://www.ruby-forum.com/t/uninitialized-constant/134658/2 "2008-04-13T16:47:58Z")

</div>

On 13 Apr 2008, at 15:35, Lee F. wrote:

> tell I’m new to rails so hoping this is some newb error…

Well it’s nice that we can see the error messages, but the code would  
be more helpful 🙂 (eg what’s on exercises\_controller on line 12 ?)

Fred

---

<div class="post-metadata">

**Author:** ![lfeistel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecc23a/32.png) [@lfeistel](https://www.ruby-forum.com/u/lfeistel)\
**Post date:** [April 13, 2008, 4:58pm UTC](https://www.ruby-forum.com/t/uninitialized-constant/134658/3 "2008-04-13T16:58:14Z")

</div>

good call… sorry mate

line 11-13 look like this

def list  
@exercises\_pages, @exercises = paginate :exercises, :per\_page =\> 10  
end

which is the same as was generated for the previous controllers.  
The page should be generating a list of exercises currently in the  
database, it might be worth pointing out that exercises/new works, so  
seems to be just the list method.

cheers.

---

<div class="post-metadata">

**Author:** ![lfeistel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecc23a/32.png) [@lfeistel](https://www.ruby-forum.com/u/lfeistel)\
**Post date:** [April 13, 2008, 5:26pm UTC](https://www.ruby-forum.com/t/uninitialized-constant/134658/4 "2008-04-13T17:26:14Z")

</div>

On 13 Apr 2008, at 15:58, Lee F. wrote:

> good call… sorry mate
> 
> line 11-13 look like this
> 
> def list  
> @exercises\_pages, @exercises = paginate :exercises, :per\_page =\> 10  
> end  
> is the Class name Exercise or Exercises. I’m going to guess that it’s  
> the latter. paginate is being smart and assuming that if you say  
> exercises, then the name of the model is the singular (ie exercise).  
> I’ll further guess that the difference is that when you created the  
> scaffold you’ve recently been using the plural form, whereas you  
> should be using the singular.

Fred

---

<div class="post-metadata">

**Author:** ![lfeistel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecc23a/32.png) [@lfeistel](https://www.ruby-forum.com/u/lfeistel)\
**Post date:** [April 13, 2008, 5:30pm UTC](https://www.ruby-forum.com/t/uninitialized-constant/134658/5 "2008-04-13T17:30:41Z")

</div>

Frederick C. wrote:

> On 13 Apr 2008, at 15:58, Lee F. wrote:
> 
> > good call… sorry mate
> > 
> > line 11-13 look like this
> > 
> > def list  
> > @exercises\_pages, @exercises = paginate :exercises, :per\_page =\> 10  
> > end  
> > is the Class name Exercise or Exercises. I’m going to guess that it’s  
> > the latter. paginate is being smart and assuming that if you say  
> > exercises, then the name of the model is the singular (ie exercise).  
> > I’ll further guess that the difference is that when you created the  
> > scaffold you’ve recently been using the plural form, whereas you  
> > should be using the singular.
> 
> Fred

I just ran scaffold exercise and it’s running fine now, thanks Fred! I  
guess I paid the price for being a little too cocky after i set up the  
first few controllers.

Cheers!  
Lee
