活动管理员渲染编辑页面

我可以很容易地重定向,但我想在validation失败时渲染编辑页面,所以我将所有validation方法都转移到表单中。 我不确定如何使用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 

你试过这个吗?

 render active_admin_template('edit.html.arb'), :layout => false 

我有一个类似的问题,但我重写了创建控制器,并希望所有活动的管理员上帝渲染错误messaegs。 所以这就是我所做的

 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 

你可以尝试类似的东西