6

I can easily redirect but I'd like to do a render the edit page on validation failure so I carry over all the validation methods into the form. I'm not sure how to render the edit action using active_admin.

If I try render :action => 'edit' I get a template missing page I also tried render active_admin_template('edit.html.arb') which gives me a page within a page, but no errors.

Any ideas?

  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
4

2 回答 2

5

你试过这个吗?

render active_admin_template('edit.html.arb'), :layout => false
于 2011-10-26T20:15:19.113 回答
3

我有一个类似的问题,但是我覆盖了创建控制器,并希望所有活动的管理员都能够呈现错误消息。所以这就是我所做的

controller do
 layout 'active_admin',  :only => [:create,:my_collection_method,:my_member_method]

 def create
 //my code here
 end
end

所以基本上,我在我的控制器部分添加了'layout "active_admin"' 行并添加了我所有的自定义方法。因此,“my_collection_method”是活动 amdin 资源中的自定义收集操作,例如

:my_collection_action, :method=>:get do
//my code here
end

你可以尝试类似的东西

于 2012-07-30T11:47:33.163 回答