Forum: Ruby on Rails No Method Error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
434eecf2bd6df521bfd599e403be9996?d=identicon&s=25 Alana (Guest)
on 2006-04-04 12:35
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:  <p>
18:  <b>User:</b><br/>
19:  <select name="tblregisteredphone[tbluser_id]">
20:  <% @tblusers.each do |tbluser| %>
21:  <option value="<%= tbluser.id %>"
22:  <%= tbluser.txtforename %>
23:  </option>

RAILS_ROOT: ./script/../config/..
Application Trace | Framework Trace | Full Trace

#{RAILS_ROOT}/app/views/tblregisteredphone/new.rhtml:20

Alana
B26c571d17b3022ab1a98c1a223c32e6?d=identicon&s=25 David Thomson (Guest)
on 2006-04-04 12:45
(Received via mailing list)
On 04/04/06, Alana <alana@c4l.co.uk> 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
434eecf2bd6df521bfd599e403be9996?d=identicon&s=25 Alana (Guest)
on 2006-04-04 12:48
> 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
B26c571d17b3022ab1a98c1a223c32e6?d=identicon&s=25 David Thomson (Guest)
on 2006-04-04 12:54
(Received via mailing list)
On 04/04/06, Alana <alana@c4l.co.uk> 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
434eecf2bd6df521bfd599e403be9996?d=identicon&s=25 Alana (Guest)
on 2006-04-04 12:58
Thanks for your help! I'm new to rails and ruby, so learning as I go! :)

Alana
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2008-01-21 21:01
(Received via mailing list)
On Jan 20, 2008 7:52 PM, G-man <gregor007@gmail.com> wrote:
> I've set up my tests, and when I run the whole thing, I get this for my
> views:
>
> 3)
>  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.
This topic is locked and can not be replied to.