Skip to content

Instantly share code, notes, and snippets.

@KarthiPnsmy
Created April 20, 2012 12:22
Show Gist options
  • Save KarthiPnsmy/2428172 to your computer and use it in GitHub Desktop.
Save KarthiPnsmy/2428172 to your computer and use it in GitHub Desktop.
#in my controller (following code works fine)
def index
p User.current.communications.size
@msg = Communication.find(:all)
@msg.each do |note|
p note.user.name
end
end
#in my index.html.erb (i am getting error)
<%for message in @msg %>
<div style="padding-bottom:5px;float:left;width: 70%;">
<%= message.user.name %>
</div>
<% end %>
#i got the following error
undefined method `name' for nil:NilClass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment