Here are my models:
class Account < ActiveRecord::Base
has_many :users
# Data name:string
class User < ActiveRecord::Base
belongs_to :account
So when I try to call for the name of the Account associated to User in view index.html.erb:
<%= user.account.name %>
I get error
NoMethodError in Users#index
undefined method `name' for nil:NilClass
Does it have to do with my controller?
def index
@users = User.all
end