I have a Location model that is polymorphic via :locatable
An Event has a Location:
class Event < ApplicationRecord
has_one :location, as: :locatable
end
In the events_controller#create, how can I create a new Event with the location passed in via params?
def create
property = Event.create! params.require(:event).permit(:name, :time, :location, :organizer_id, attachments: [])
# ... other stuff, and finally render JSON response
end
However, Event.location is nil. How can I create a location for the Event?
Thanks