Multiple models to describe a rental process in rails -


i have two-sided rental marketplace , bookings have been described 1 model. stores status renter requesting, owner accepting / rejecting, booking finished etc.

create_table "bookings" |t|    # storing booking time info    t.datetime "pickup_datetime"    t.datetime "return_datetime"     # create snapshots of state of product @ time of rental requests submission    t.integer  "hourly_rate"    t.integer  "weekly_rate"    t.integer  "daily_rate"     # storing states    t.datetime "requested_at"    t.datetime "accepted_at"    t.datetime "rejected_at"    t.datetime "cancelled_at"    t.datetime "created_at"    t.datetime "updated_at"    t.datetime "owner_reviewed_at"    t.datetime "renter_reviewed_at"     t.integer "renter_id"    t.integer "product_id"  end 

i found clumsy , decided break down 3 models

rental::intent -> renter's intention make booking. each intent has_many requests, , first reuqests confirms become booking. intent stores payment status , rental time info not duplicated in each request , renter have pay deposit once.

rental::request -> request object different product, each has status: e.g. cancelled, expired, accepted, rejected ..etc

rental::booking -> confirmed request becomes bookings

so know can summarise activerelationship belongs_to, has_many ..etc. however, not sure how describe process within model described above. e.g. requests becomes bookings when requests gets confirmed.

i wondering general approach when dealing process this?


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -