# No Method Error

**URL:** <https://www.ruby-forum.com/t/no-method-error/93524>\
**Category:** Rails\
**Created:** [April 4, 2006, 12:35pm UTC](https://www.ruby-forum.com/t/no-method-error/93524 "2006-04-04T12:35:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9de053/32.png) [@alana](https://www.ruby-forum.com/u/alana)\
**Post date:** [April 4, 2006, 12:35pm UTC](https://www.ruby-forum.com/t/no-method-error/93524/1 "2006-04-04T12:35:24Z")

</div>

This is the error that keeps appearing. I don’t understand why  
“@tblusers” is not correct. Can anyone help?

NoMethodError in Tblregisteredphone#new

Showing app/views/tblregisteredphone/new.rhtml where line #20 raised:

You have a nil object when you didn’t expect it!  
You might have expected an instance of Array.  
The error occured while evaluating nil.each

Extracted source (around line #20):

17:

18: **User:**  
  
19:   
20: \<% @tblusers.each do |tbluser| %\>  
21: \<option value="\<%= tbluser.id %\>"  
22: \<%= tbluser.txtforename %\>  
23:

RAILS\_ROOT: ./script/…/config/…  
Application Trace | Framework Trace | Full Trace

#{RAILS\_ROOT}/app/views/tblregisteredphone/new.rhtml:20

Alana

---

<div class="post-metadata">

**Author:** ![alana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9de053/32.png) [@alana](https://www.ruby-forum.com/u/alana)\
**Post date:** [April 4, 2006, 12:45pm UTC](https://www.ruby-forum.com/t/no-method-error/93524/2 "2006-04-04T12:45:39Z")

</div>

On 04/04/06, Alana [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> This is the error that keeps appearing. I don’t understand why  
> “@tblusers” is not correct. Can anyone help?

What does the code for the “new” method in your controller say? I can  
only assume that @tblusers isn’t being set properly there, but if you  
post the method then we can help more.

Thanks,  
David

---

<div class="post-metadata">

**Author:** ![alana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9de053/32.png) [@alana](https://www.ruby-forum.com/u/alana)\
**Post date:** [April 4, 2006, 12:48pm UTC](https://www.ruby-forum.com/t/no-method-error/93524/3 "2006-04-04T12:48:29Z")

</div>

> What does the code for the “new” method in your controller say? I can  
> only assume that @tblusers isn’t being set properly there.

The code for my “new” method in the controller is as follows:

```
def new
	@tblregisteredphone = Tblregisteredphone.new
	@tbluser = Tbluser.find_all
end

```

Thanks David,

Alana

---

<div class="post-metadata">

**Author:** ![alana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9de053/32.png) [@alana](https://www.ruby-forum.com/u/alana)\
**Post date:** [April 4, 2006, 12:58pm UTC](https://www.ruby-forum.com/t/no-method-error/93524/4 "2006-04-04T12:58:39Z")

</div>

Thanks for your help! I’m new to rails and ruby, so learning as I go! 🙂

Alana

---

<div class="post-metadata">

**Author:** ![alana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9de053/32.png) [@alana](https://www.ruby-forum.com/u/alana)\
**Post date:** [April 4, 2006, 12:54pm UTC](https://www.ruby-forum.com/t/no-method-error/93524/5 "2006-04-04T12:54:59Z")

</div>

On 04/04/06, Alana [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The code for my “new” method in the controller is as follows:
> 
> ```
> def new
> @tblregisteredphone = Tblregisteredphone.new
> @tbluser = Tbluser.find_all
> end
> 
> ```

Ah - the problem is that you set @tbluser in your controller, but then  
use @tblusers in the view! Pretty easy to fix 🙂

David

---

<div class="post-metadata">

**Author:** ![alana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9de053/32.png) [@alana](https://www.ruby-forum.com/u/alana)\
**Post date:** [January 21, 2008, 9:01pm UTC](https://www.ruby-forum.com/t/no-method-error/93524/6 "2008-01-21T21:01:23Z")

</div>

On Jan 20, 2008 7:52 PM, G-man [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’ve set up my tests, and when I run the whole thing, I get this for my  
> views:
> 
> 1. 
> 
> NoMethodError in ‘/chapters/new.html.erb should render new form’  
> undefined method `process\_clean\_up\_fixtures’ for  
> #Spec::Rails::Example::ViewExampleGroupController:0x447ddcc  
> c:/rails/rails\_apps/tracker/spec/views/chapters/new.html.erb\_spec.rb:15  
> script/spec:4:

Can we see some code? What do the spec and the view look like?

> Usage: -e [options] [-- untouched arguments]  
> There was another thread about this just a day or two ago. Not sure  
> what exactly the problem is, but there seems to be conflict with  
> redgreen and the changes to autotest in ZenTest-3.8.0. Get rid of that  
> and it should work.
