简体   繁体   中英

active admin render edit page

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

你试过这个吗?

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

I had a similar issue, but I was overriding the create controller and wanted all the active admin godness for rendering error messaegs. So here is what I did

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

 def create
 //my code here
 end
end

So basically, i added the 'layout "active_admin" ' line in my controller part and added ALL my custom methods. So the 'my_collection_method' is a custom collection action in the active amdin resource, something like

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

You could try something similar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM