Q:

Not able to access related objects fields

So I'm new to rails and I'm not entirely sure what I'm doing wrong. Everything I've read says that I'm doing this right. 
I have a relationships between two models. 
class Photo < ActiveRecord::Base
     has_many :votes
     belongs_to :user
  end 

And 
class User < ActiveRecord::Base
  attr_accessible :username, :email, :password, :password_confirmation, :remember_me
  has_many :votes
  has_many :photos
end

Here are my Controller methods
def index 
  @photos = Photo.order("created_at desc").to_a 
end

def create
    @photo = Photo.new(params[:photo])
    @photo.user_id = current_user.id
    if !@photo.save
      @error = @photo.errors.full_messages.join('. ')
      render view_for_new
      return
    end
  end

I know the relationship works because in my view when I do this: <%= photo.user %> I get a user object back, and when I do <%= photo.user.inspect %> it shows all the expected fields with the correct keys and values. 
However I want to access fields such as username, email, etc and display those on the page. How do I do this? I've tried doing <%= photo.user.email %> and some other fields that are available but it doesn't seem to be working

A:

Alright figured this out, or at least partially. 
Instead of <%= photo.user.email %> I did <%= photo.user.try(:email) %> and that brought the correct attribute back that I was looking for. It seems the association is done correctly. I don't know why <%= photo.user.email %> doesn't work, everywhere I look on line seems to use that sort of syntax. 

