NoMethodError

Hi,any ideas how to fix this error, im trying to create a users login.register. which i have called users1. Here is the error message i9n my view.Thanks

NoMethodError in User1#index Showing app/views/user1/index.html.erb where line #6 raised:

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

Extracted source (around line #6):

3: 4: <h1>Users1</h1> 5: <ol> 6: <% @users.each do |user1| %> 7: <li><%= user1.screen_name %></li> 8: <% end %> 9: </ol>

My Controller

class User1Controller < ApplicationController   def index     @title = "Temporary View"     @users = User1.find(:all)   end

  def register     @title = "Register"

  if @user.save         flash[:notice] = "User with login #{@user.screen_name} created successfully!"         print "1_User with login #{@user.screen_name} created successfully!"         redirect_to :action => :index       else         print "2_User with login #{@user.screen_name} created successfully!"         #print "3_User with login #{@user1.screen_name} created successfully!"       end     end end

  def login   end

my database Migration

class CreateUser1s < ActiveRecord::Migration   def self.up     create_table :user1s do |t|       t.string :screen_name       t.string :e_mail       t.string :password

      t.timestamps     end   end

  def self.down     drop_table :user1s   end end

How about trying 'User1.find(:all)' in the console ('rails console')?

Or use the debugger and step into the index method to see if/where @users isn't being populated.

Simon M. wrote in post #976391:

Hi,any ideas how to fix this error, im trying to create a customer login/register page. which i have called users1.

Off topic, but...why call them users1? If they're customers, just call them that. Keep your names meaningful.

Best,