Wondering about combining has_one and has_many in one application

I am writing an app for a foodbank. The edit screen uses a database
called visit with fields of household_id, month, year, monthly, and
weekly. Household_id is a link to another database with family
records, month and year are for the date of this record, monthly is
for a monthly visit, and weekly is for a weekly fruit and bread visit.
In the edit screen the Household database has a has_one relationship
with Visit, so it only finds 1 record and asks about attendance this
month. The problem comes when I try to make a report using has_many.
The report shows attendance for the calendar year.

I’m sure there is a way to do this with Rails, but I have no idea, so
please help…

Bob

On 28 February 2010 20:36, Bob S. [email protected] wrote:

I am writing an app for a foodbank. The edit screen uses a database
called visit with fields of household_id, month, year, monthly, and
weekly. Household_id is a link to another database with family
records, month and year are for the date of this record, monthly is
for a monthly visit, and weekly is for a weekly fruit and bread visit.
In the edit screen the Household database has a has_one relationship
with Visit, so it only finds 1 record and asks about attendance this
month. The problem comes when I try to make a report using has_many.
The report shows attendance for the calendar year.

Relationships have nothing to do with the views you choose to display,
but reflect the fundamental relationships of the real-world objects
that you are mapping using the database. Think first about these
models and their relationships and then build the views you want on
top of that.

So for example if Household has_many Visits then you may choose to
only show one or ones occurring in a particular week, but that does
not change the relationship itself.

Also it is unusual to use more than one database, or did you mean
tables?

I do not know how much experience you have with Rails but if that is
not a lot you may like to work through some of the guides at
http://guides.rubyonrails.org. There is one on ActiveRecord
Relationships which may help. Also check out the others.

Colin