# Noobie controller model method difficulty

**URL:** <https://www.ruby-forum.com/t/noobie-controller-model-method-difficulty/145485>\
**Category:** Rails\
**Created:** [August 10, 2008, 5:42pm UTC](https://www.ruby-forum.com/t/noobie-controller-model-method-difficulty/145485 "2008-08-10T17:42:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tyliong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9a140/32.png) [@tyliong](https://www.ruby-forum.com/u/tyliong)\
**Post date:** [August 10, 2008, 5:42pm UTC](https://www.ruby-forum.com/t/noobie-controller-model-method-difficulty/145485/1 "2008-08-10T17:42:20Z")

</div>

I am a real newbie at rails please help me. I have a controller called  
groceries and a model also called groceries. I generated both the  
model and controller with the /script.

I thought inside the controller i could call the model but it doesn’t  
seem to work.

[  
class GroceriesController \< ApplicationController

def index  
@groceries = groceries.find(:all)  
respond\_to do |format|  
format.html # index.html.erb  
format.xml { render :xml =\> @groceries }  
end  
end

]

groceries.find(:all) gives undefined variable or method

Do i need to make a scaffold ? is there something more i need to do to  
associate the model with the controller?

---

<div class="post-metadata">

**Author:** ![tyliong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9a140/32.png) [@tyliong](https://www.ruby-forum.com/u/tyliong)\
**Post date:** [August 10, 2008, 5:44pm UTC](https://www.ruby-forum.com/t/noobie-controller-model-method-difficulty/145485/2 "2008-08-10T17:44:40Z")

</div>

On Aug 10, 4:33 pm, tyliong [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> def index
> 
> ```
> 
> Do i need to make a scaffold ? is there something more i need to do to  
> associate the model with the controller?

You don’t need to do anything to ‘associate’ a model with a controller  
(because there isn’t really such an association).  
The only think here is that your model is Grocery (or Groceries, but  
should probably be the former) and so you need to do Grocery.find :all  
(or Groceries.find :all)

Fred
