我可以很容易地重定向,但是我想在驗證失敗時渲染編輯頁面,所以我將所有的驗證方法都放在窗體中。我不確定如何使用active_admin呈現編輯操作。活動管理器渲染編輯頁面
如果我嘗試render :action => 'edit'
我得到一個模板缺頁 我也試過render active_admin_template('edit.html.arb')
它給了我一個頁面內的頁面,但沒有錯誤。
任何想法?
member_action :state do
space = Space.find(params[:id])
if space.send(params[:state])
#space.send(params[:state]+"!")
flash[:notice] = "State Changed!"
redirect_to :action => :index
else
#render :action => 'edit'
#render active_admin_template('edit.html.arb')
flash[:error] = "#{space.errors}"
redirect_to :action => :edit
end
end
這解決了佈局嵌套的問題,但反正是有它突出的領域驗證失敗?在正常的方式編輯會?目前我通過flash方法傳遞他們:「{:photos => [」沒有足夠的條目「],:blurb => [」您的留言必須至少有50個單詞。「}}」 – holden
不確定,抱歉。但是我也可能需要爲我目前的項目解決這個問題。 –
此方法在更新版本中不存在 - 有關替代解決方案,請參閱http://stackoverflow.com/questions/6653093/activeadmin-how-to-render-default-template-in-customized-action/36665082#36665082 –