My model:
user has many events through statistics and registrations
registrations contains whether or not the user was on the event,
statistics contains what he did on the event.
I think it is better to make 2 tables since I don't need a statistics
record if the user was not present (registration.present = 0). But
maybe someone has an other view ont this?
I want to create a eventview (show) where an admin can enter/change
the event data. The admin should be able to insert whether the user
was present (with a checkbox) and if present a form is shown on the
same row where the statistics data can be entered (minutes
present, ...).
I'm trying to edit 2 models here: statistics and registrations.
The problem is that I don't really have a clue on where to start.
registrations contains whether or not the user was on the event,
statistics contains what he did on the event.
So basically,
if user was at event
registration = yes
statistics = data on user's attendence
else
registration = no
end
It seems like your registration model's primary purpose is to indicate
whether attendance occurred, thus creating the need for a statistics
entry. Instead, you should do:
a user :has_many :events, :through => :attendances
attendance will do everything that your statistics model does. more
importantly, its _presence_ indicates that a registration occurred,
and if it's not there, it means that a registration has not occurred.
Regardless of whether I understood your problem or not: using models
for join tables (HABTM :through relationships) allows you to talk as
directly to rails about the _relationship_ between objects as you talk
about the objects themselves. This is a powerful and widely-applicable
concept.
will dynamically insert form markup in eRB inside your views based on
YAML specifications. It will speed up construction, and make your
forms quite maintainable.