2016-12-14 19 views
0

我有一個代碼具有影響者的關聯。 我想在代碼表單中顯示影響者用戶名爲readonly。在Active Admin中更改只讀輸入文本

現在我做:

form do |f| 
f.inputs 'Code' do 
    f.input :influencer, input_html: { readonly: true, disabled: true }, as: :string if !f.object.new_record? 

但我得到這個,我想影響者姓名或用戶名。

I need a field displayed. Not the object.

想法?

回答

0

我結束了在代碼模型

delegate :username, to: :influencer, prefix: true, allow_nil: true 

,並加入這一行那麼這個形式:

f.input :influencer_username, 
      label: 'Influencer', 
      input_html: { readonly: true, disabled: true }, 
      as: :string unless f.object.new_record?