First, thanks to everyone who replied to my pluralization question
from before!
Today I was trying to do what I think is called a “chained accessor”.
I have an “events” table and each event has one user. Instead of
seeing the id number for each event’s user, I’d rather display the
names of users instead. I tried to do this:
class Event < ActiveRecord::Base
belongs_to :user
end
class User < ActiveRecord::Base
has_many :events
end
in the event_controller.rb:
def list @users = User.find(:all) @events = Event.find(:all)
end
in the list.rhtml:
<% @events.each do |eachevent| %>