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
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
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.
On Jan 20, 5:40 pm, "Simon M."
<li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> 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
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
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, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org Sent from my iPhone -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.