mercredi 7 décembre 2016

Rails model association to hold each month data

Could not find a appropriate title to this question sorry for that.

I have a car model. I would like to keep the data of daily and hourly price for each of the month. I could not figure it out how I should construct the model relations.

I tried car has_many dprices (daily price) with columns of month:string price:integer

then I tried car has_many hprices (hourly price) with columns of month:string price:integer

Then I tried nested forms. But it does not deliver the data as I want.

"car"=>{"prices_attributes"=>{"0"=>{"price"=>"123"}}

This looks so complicated. What I want is to get month name and price if possible.

It should look like this;

enter image description here

Thank you

Aucun commentaire:

Enregistrer un commentaire