Ruby on rails 4 Rails管理-更新前的消息
我使用rails\u adminRuby on rails 4 Rails管理-更新前的消息,ruby-on-rails-4,rails-admin,Ruby On Rails 4,Rails Admin,我使用rails\u admin 有人知道我如何在更新前显示确认消息(带有操作)吗 我将创建自定义操作或覆盖现有操作。大概是这样的: class Update2 RailsAdmin::Config::Actions.register(self) register_instance_option :visible? do # end register_instance_option :link_icon do # your icon here end r
有人知道我如何在更新前显示确认消息(带有操作)吗 我将创建自定义操作或覆盖现有操作。大概是这样的:
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
然后创建一个页面app/views/rails_admin/main/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上它将实际更新 我将创建自定义操作或覆盖现有操作。大概是这样的:
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
然后创建一个页面app/views/rails_admin/main/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上它将实际更新 谢谢,这可能是一个解决方案。谢谢,这可能是一个解决方案。