# Creating/Storing Attendance Records for different Rooms

**URL:** <https://www.ruby-forum.com/t/creating-storing-attendance-records-for-different-rooms/161797>\
**Category:** Rails\
**Created:** [March 2, 2009, 3:08pm UTC](https://www.ruby-forum.com/t/creating-storing-attendance-records-for-different-rooms/161797 "2009-03-02T15:08:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![noddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ac8455/32.png) [@noddy](https://www.ruby-forum.com/u/noddy)\
**Post date:** [March 2, 2009, 3:08pm UTC](https://www.ruby-forum.com/t/creating-storing-attendance-records-for-different-rooms/161797/1 "2009-03-02T15:08:22Z")

</div>

I’m developing a small rails application for my local community centre  
to help them record their attendance. The community centre (building)  
has several rooms and each room is used on a daily basis for numerous  
activities. I have the following setup:

#building.rb  
class Building \< ActiveRecord::Base  
has\_many :rooms  
end

#room.rb  
class Room \< ActiveRecord::Base  
belongs\_to :building  
has\_many :attendances  
end

#attendance.rb  
class Attendance \< ActiveRecord::Base  
belongs\_to :room  
has\_many :attendees  
end

#attendee.rb  
class Attendee \< ActiveRecord::Base  
belongs\_to :attendance  
end

I assume the following is an efficient way of recording the attendance  
figures for each room? I create a new attendance record for each of the  
rooms (daily) and then add the attendees to the attendance record. (This  
is working fine.)

In the new attendance form I have a date select and room select (listing  
all of the rooms within the building). As they have several rooms  
creating new records for each is a tedious process - I would like to  
have one form which you can select the date and once submitted it will  
create a new attendance record for all rooms in the building. A step  
further would be to have the rails app create the attendance records  
automatically each day. I would be grateful of your thoughts on how best  
this could be achieved.
