# NameError on accessing Active Record from the controller with Rails 2.0.2

**URL:** <https://www.ruby-forum.com/t/nameerror-on-accessing-active-record-from-the-controller-with-rails-2-0-2/132723>\
**Category:** Rails\
**Created:** [March 24, 2008, 3:38am UTC](https://www.ruby-forum.com/t/nameerror-on-accessing-active-record-from-the-controller-with-rails-2-0-2/132723 "2008-03-24T03:38:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 24, 2008, 3:38am UTC](https://www.ruby-forum.com/t/nameerror-on-accessing-active-record-from-the-controller-with-rails-2-0-2/132723/1 "2008-03-24T03:38:24Z")

</div>

I get following error on accessing ActiveRecord from the controller,

# log\development.log

NameError (uninitialized constant ProductsController::Question):  
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/  
active\_support/dependencies.rb:478:in `const_missing' /app/controllers/products_controller.rb:14:in`build’

# ProductsController.rb

def build  
@qs = Question.find(:all)  
end

I could not find much information relevant to my scenario on  
NameError, Please let me know, if someone have any idea on whats going  
on.

Your help be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 24, 2008, 5:24am UTC](https://www.ruby-forum.com/t/nameerror-on-accessing-active-record-from-the-controller-with-rails-2-0-2/132723/2 "2008-03-24T05:24:36Z")

</div>

What exactly is your Question? Another model in your application? From  
the looks of it, Rails doesn’t know what a Question is…

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 24, 2008, 5:43am UTC](https://www.ruby-forum.com/t/nameerror-on-accessing-active-record-from-the-controller-with-rails-2-0-2/132723/3 "2008-03-24T05:43:25Z")

</div>

Thanks for the reply. It helps to figure out the issue.

It was the model generation mistake. I have generated with model name in  
plural.

Thanks again.

On Sun, Mar 23, 2008 at 11:24 PM, Ar Chron  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
