2015-07-10 45 views

回答

0

我会创建一个自定义操作或覆盖现有的操作。事情是这样的:

class Update2 
    RailsAdmin::Config::Actions.register(self) 
    register_instance_option :visible? do 
    # 
    end 
    register_instance_option :link_icon do 
    # your icon here 
    end 
    register_instance_option :http_methods do 
    [:get, :post] 
    end 
    register_instance_option :controller do 
    Proc.new do 
     if request.post? 
     @object.update 
     flash[:notice] = "Updated #{@object.name}." 
     redirect_to show_path 
     end 
    end 
    end 
end 

然后创建一个网页应用程序/视图/ rails_admin /主/ update2.html.haml

%h3 
    = "Are you sure you want to update '#{@object.name}' 
= link_to 'Update', update2_path, method: 'post', class: "btn btn-danger" 
= link_to 'Cancel', show_path, class: "btn btn-primary" 

当您单击UPDATE2您将通过GET去的网页。然后在POST上它会实际更新。

+0

谢谢,它可以是一个解决方案。 – AlexMrKlim