No Method Error

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

On 04/04/06, Alana [email protected] 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

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

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

Alana

On 04/04/06, Alana [email protected] 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 :slight_smile:

David

On Jan 20, 2008 7:52 PM, G-man [email protected] wrote:

I’ve set up my tests, and when I run the whole thing, I get this for my
views:

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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs