2

Hi I have a model Event and this event has one Setting. e.g

class Event < ActiveRecord::Base
  has_one :setting
end

class Setting < ActieRecord::Base
  belongs_to :event
end

My event entity looks some thing like

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

My EventSettingEntity class looks something like

module Entities
  class EventSettingEntity < Grape::Entity
    expose :id, :event_id
    expose :type, documentation: { type: String, desc: "Type" }
  end
end

My Api is like

desc 'Create an event.' ,{
        params: Entities::EventEntity.documentation, type: :create
}
post 'create' do
  event = Event.create(params)
  present event, with: EventEntity
end

But the main problem is event creation form is not showing setting class type field. Please help me to resolve the issue. Thanks

Braham Shakti
  • 1,408
  • 4
  • 22
  • 39
  • Sorry, but your questions isn't clear enough. Where do you have a problem in your code? Is it related to the HTML form? Is it related to your API? Is this problem happening when you persist the model using ActiveRecord? Please, reformulate your question so I can help you out. – Marlon Aug 24 '15 at 16:54
  • Yes it is related to html form, how do I show association fields in my form? Thanks – Braham Shakti Sep 12 '15 at 19:11

0 Answers0