2013-04-23 66 views
0

您好我正在使用軌道上的紅寶石,活動管理和我有一個表有幾列,我的問題是:我可以只允許編輯其中一列?我希望用戶只需更改一個,而無需編輯權限即可刪除其他列。可能嗎?activeadmin default_actions編輯一個值

actions :all, :except => [:destroy] 
.......... 
index do 
    selectable_column 
    ........... 
    .............. 
    end 
    default_actions :name => "Actions" 
end 

任何幫助將不勝感激!謝謝!

+0

你確定編輯表單只有一列可以編輯嗎? – manoj 2013-04-23 09:56:52

+0

你是說如果我喜歡現在編輯的方式?是的,我喜歡,但重點是,現在它也允許編輯其他列,這就是我不想要的。 – Anna 2013-04-23 10:30:44

回答

0

您可以定義表單中顯示爲編輯

index do 
    .... 
    end 
    form do |f| 
    f.inputs "Some heading" do 
     if f.object.persisted? 
     #is shown when editing an existing object 
     f.input :field1 
     else 
     #is shown when creating a new object 
     f.input :field1 
     f.input :field2 
     end 
    end 
    f.actions 
    end 

只會呈現形式已添加的字段。

+0

非常感謝! :) – Anna 2013-04-23 12:09:19