嗨,我有一个模型Event
,这个活动有一个Setting
。例如
class Event < ActiveRecord::Base
has_one :setting
end
class Setting < ActieRecord::Base
belongs_to :event
end
我的事件实体看起来像
module Entities
class EventEntity < Grape::Entity
expose :id
expose :name, documentation: { type: String, desc: "Event name", required: true}
expose :setting, using: Entities::EventSettingEntity
end
end
我的EventSettingEntity
课看起来像
module Entities
class EventSettingEntity < Grape::Entity
expose :id, :event_id
expose :type, documentation: { type: String, desc: "Type" }
end
end
我的 Api 就像
desc 'Create an event.' ,{
params: Entities::EventEntity.documentation, type: :create
}
post 'create' do
event = Event.create(params)
present event, with: EventEntity
end
但主要问题是事件创建表单没有显示setting
类type
字段。请帮我解决问题。谢谢