I have a venue model and i want to do this
Venue.find_or_create_by_
but i only want a new venue to be created if one with the same name and date do not already exist
For example
=> Venue(id: integer, location: string, showdate: datetime, created_at: datetime, updated_at: datetime)
A venue is unique and needs to be created if the location and the showdate are not present in the db
You can chain columns together by using _and_
. This should do the trick:
Venue.find_or_create_by_location_and_showdate(location, showdate)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With