Active Rendering Edit Page

I can easily redirect, but I would like to render the edit page when the validation fails, so I transfer all the validation methods to the form. I am not sure how to do the editing action using active_admin.

If I try render :action => 'edit' , I will get a missing template page. I also tried render active_admin_template('edit.html.arb') , which gives me a page on the 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 
+6
source share
2 answers

Have you tried this?

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

I had a similar problem, but I redefined the creation controller and wanted all active admins to be created to create messaegs errors. 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 line "layout" active_admin "in my part of the controller and added ALL my own methods. So," my_collection_method "is the action of the user collection in the active amdin resource, something like

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

You can try something like that

+3
source

Source: https://habr.com/ru/post/892510/


All Articles