Topic: Need help with 10.3 Michael Hartl's rails 3 toutorial
I am trying to create an index action and view for the User model.
In my users controller the index action is defined as:
@title = "All users"
@users = User.all
And in the index.html.erb:
<% @users.each do |user| %>
<%= gravatar_for user, :size => 30 %>
<%= link_to user.name, user %>
<% end %>
When I launch it in the browser I get an undefined method error:
undefined method `email' for nil:NilClass
I know gravatar_for searches its first parabiter for the value of the :email key so I am almost sure this is where it locks up. I tried
firing it up in the rails console.
>> users = User.all
returns an array of all my users
but when I try to itterate through all of them
>> users.each do |u|
it shows no out put and the return is the same as above
I would greatly appriciate any help I am almost done with this toutorial and am really looking forward to learning the more creative aspects of rails.
Hope all is well
Last edited by tystick86 (2011-03-18 03:15:24)