Association trhough checkboxes

I need some help to make the right solution in rails. I have this
model in rails:

Customer – has many – Reservations
Customer – has many – Animals
Reservatiion – has many – Residences – has one – Animal

A customer can make a reservation for the animals he/she is owner of.
I made a view where I show the customer with two fields for the
reservations and the animals which belongs to the customer. I use
checkboxes for the animals to (un)check them for the reservation.

I get everything the work, however when some of the validations fails
I loose some information of my model. I use ryanb´s solution for
multiple models in a view. But in my model I check if the residence
must be made (if the checkbox is checked). I do something like this

def new_residence_attributes(=new_residence_attributes)
  loop atrributes if attribute[:status] == :reserved

So only the residences I build come back in my controller, so I loose
some information when I come back in my controller (only residences
which are reserved). The question how do I preserve the original model
created in the controller with the values of the view.

Thanks for your help in advance.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs