Rails find or create based on two fields

Viewed 13295

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

3 Answers
Related