I have a 1:1 has_one / belongs_to relationship between users and registrations. One user has one registration.
When I try to iterate through users in a view and display their registration info (source to follow), I get the following error:
ActionView::TemplateError: You have a nil object when you didn't expect it! The error occurred while evaluating nil.registration_code
Here's the offending view code:
<% @users.each do |user| %>
<%= user.registration.registration_code %>
<% end %>
In my users_controller.rb:
def users_registration_codes
@users = User.find(:all)
end