I’m obviously missing something simple. I have two models containing the
class Userlevel <ActiveRecord::Base
class User < ActiveRecord::Base
userlevels is a table with id as the primary key. The users table has a
column userlevel_id that links it to the userlevels table.
In my controller, I have
@users = User.find(:all)
In my view I have
<%= for user in @users %>
<%= user.userlevel.usertype %>
At this point I get a “NoMethodError: undefined method `userlevel’ for
#User:0xb753abd0”. I’m looking at the example in Agile Web
Development, and my code looks right to me. Why can’t I get the
associated data from userlevels table? What am I missing? It’s probably
obvious to the guru’s here.