我正在设置单表继承,使用 ContactEvent 作为 ContactEmail、ContactLetter 和 ContactCall 都将继承的模型。
但我对如何创建路由和控制器感到困惑。
例如,假设我想创建一个类型为 Email 的新 ContactEvent。
我想要一种方法来执行以下操作:
new_contact_event_path(contact, email)
这将采用来自联系人模型和电子邮件模型的实例。
在里面,我想contact_event_controller 需要知道......
@contact_event.type = (params[:email]) # get the type based on what was passed in?
@contact_event.event_id = (params[:email]) #get the id for the correct class, in this case Email.id
只是不确定这是如何工作的......