Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <% @blog.comments.each do |comment| %>
- <h3><%= comment.user.email %></h3>
- </div>
- <% end %>
- NoMethodError in Blogs#show
- ...
- undefined method `email' for nil:NilClass
- <% @blog.comments.each do |comment| %>
- <%= comment.body %>
- <% end %>
- class Comment < ActiveRecord::Base
- belongs_to :blog
- belongs_to :user
- end
- <% @users.each do |user| %>
- <tr>
- <td><%= link_to user.username, user %></td>
- <td><%= user.email %></td>
- </tr>
- <% end %>
- <% @blog.comments.each do |comment| %>
- <h3><%= comment.user.email if comment.user %></h3>
- </div>
- <% end %>
- <%= comment.user.try(:email) %>
- <%= comment.user.try(:email) %>
Add Comment
Please, Sign In to add comment