opensourcecatholic / marriage-booklet

To help Catholic couples plan their wedding mass
4 stars 2 forks source link

generate the User and WeddingParty models #29

Closed JohnRDOrazio closed 3 years ago

JohnRDOrazio commented 3 years ago

With PR #24, the Projects models, controllers and views were generated.

Now we need to integrate the Users model and the WeddingPartyMembers model.

Keeping in mind @mftruso 's observations on the hasMany model, do we only need to generate the models? Or do we also need controllers and views?

I don't think we need a separate view for the WeddingPartyMembers, I believe we can just integrate into the Projects view, since the WeddingPartyMembers only exist in a Project. However we will need to take care of them being inserted into the database upon creating a new project or updating an existing project (how? where is the logic that takes care of the form posting? Is that in a controller?). Or perhaps the scaffold generator is useful anyways, seeing it also generates functional tests? Then we could just simply not use the routes or views that we don't need?

In any case a view for the Users model might come in handy, so we can have a separate area where a user can create or update their password, edit / verify their email, etc. So perhaps we should use the scaffold generator in this case?

This is what I have so far for the models we've been discussing:

bundle exec rails generate scaffold Project liturgy:integer brideFirstName:string brideLastName:string groomFirstName:string groomLastName:string celebrantNamePrefix:string celebrantFirstName:string celebrantLastName:string church:string city:string weddingdate:datetime

bundle exec rails generate scaffold User username:string email:string role:integer password_digest:string project:references

bundle exec rails generate scaffold WeddingPartyMember partyMemberFirstName:string partyMemberLastName:string partyMemberRole:integer partyMemberRelationship:string project:references

This first scaffold of the three is already taken care of. For the next two, I believe that project:references should take care of the hasMany relationship? Or does another step need to be taken?

@mftruso you might have a better grasp on how to handle the next steps, following PR #24?

JohnRDOrazio commented 3 years ago

In the WeddingPartyMembers model, should we define partyMemberRole as an enum also? With a predefined set of roles such as Father, Mother, Parent, Grandparent, Grandfather, Grandmother, Brother, Sister, Friend, Aunt, Uncle etc. ? Or would that be better left as a string, for greater freedom, simply offering some of these suggestions in the UI?

I figured we could have two fields at this point, partyMemberRole and partyMemberRelationship. The first would be one of the above mentioned roles, the second would offer a list of suggestions such as of the Bride, of the Groom, of the Bride and the Groom, of the Family of the Bride, of the Family of the Groom.

JohnRDOrazio commented 3 years ago

User and WeddingPartyMember models have been generated in the new git history