-
I would like to use actions to delete a record and I currently have def handle(models: :page, fields:)
models.each do |model|
if model.published
fail 'You cannot delete a page that is currently published'
else
model.destroy
end
succeed 'The record has been deleted'
redirect_to '/home'
end
end However this does not work and the object is not deleted/destroyed as the form sends POST request. How can I send DELETE and make this work? Many thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 13 replies
-
+ def handle(models:, fields:)
- def handle(models: :page, fields:)
models.each do |model|
if model.published
fail 'You cannot delete a page that is currently published'
else
model.destroy
end
succeed 'The record has been deleted'
redirect_to '/home'
end
end |
Beta Was this translation helpful? Give feedback.
-
`Started POST "/uk/bj-admin/resources/pages/actions/delete_record" for 127.0.0.1 at 2021-05-27 15:07:36 +0100 Not notifying due to notify_release_stages :["staging", "production"] Our team is nice. ", created_at: "2021-05-27 14:05:08", updated_at: "2021-05-27 14:05:08", slug: "our-team", published: nil, ancestry: "4">]
SystemExit - [#<Page id: 9, name: "Our Team", meta_title: "", meta_description: "", content: " Our team is nice. ", created_at: "2021-05-27 14:05:08", updated_at: "2021-05-27 14:05:08", slug: "our-team", published: nil, ancestry: "4">]:app/avo/actions/delete_record.rb:7:in handle'
|
Beta Was this translation helpful? Give feedback.
-
I got it working now. Restarted and tested on published page. This can be closed now. Thank you. |
Beta Was this translation helpful? Give feedback.
I got it working now. Restarted and tested on published page. This can be closed now. Thank you.