我可以很容易地重定向,但我想在验证失败时渲染编辑页面,所以我将所有验证方法都转移到表单中.我不确定如何使用active_admin呈现编辑操作.
如果我尝试渲染:action => ‘编辑’我得到一个缺少模板的模板
我也试过渲染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