I am having a hard time seeing how some aspects of associations
For instance, I have a “Role” class with a “has_many :users” assoc.
and a "User: class with a “belongs_to :role” assoc., when I run this
sample code in the console “u = User.find(:all)” and then “u.methods”
I do not see the new role related methods in the methods list, same if
I run the similar code for “Role”, no new user methods.
However, I run “u = User.new” then “u.methods” the new role methods
show that they have been added to the “u” object.
Since this is the case, I am stumped as to how running something like
“@users = User.find(:all)” in the user’s controller’s index action
allows me to successfully use <% for user in @users %> <%=h
user.role.name %> <%end%> etc. in my views.
Thanks for the help here.