我尝试在更新模型之前创建自定义操作来处理某些信息。 我对编辑操作有两个操作(一个用于获取动词,另一个用于帖子)。
我关注了activeadmin文档,以下是我已经尝试过的内容:
ActiveAdmin.register Cliente do
permit_params :nome, :caminho_imagem
actions :all
collection_action :edit, method: :post do
byebug
end
end
ActiveAdmin.register Cliente do
permit_params :nome, :caminho_imagem
actions :all
member_action :edit, method: :post do
byebug
end
end
ActiveAdmin.register Cliente do
permit_params :nome, :caminho_imagem
actions :all
member_action :edit, method: [:post] do
byebug
end
end
在上面的任何一个例子中,当我 GET 进入编辑页面时,会触发byebug。我做错了什么?
答案 0 :(得分:1)
ActiveAdmin docs使用了此
if request.post?
在他们的例子中
member_action :foo, method: [:get, :post] do
if request.post?
resource.update_attributes! foo: params[:foo] || {}
head :ok
else
render :foo
end
end
我认为您可能需要这样做。