I want to implement a user action (notify_all) on my activeadmin Users page, which when clicked will display a form that will be redirected to another user action (send_notification_to_all) when submitted. So far, I have not been able to get the second part to work.
admin / users.rb:
ActiveAdmin.register User do
action_item :only => :index do
link_to 'Notify All', notify_all_admin_users_path
end
collection_action :notify_all, :method => :get do
puts "notifying...."
end
collection_action :send_notification_to_all, :method => :post do
puts "sending notification...."
end
end
When you click the Notify All button, the following view is displayed. views / admin / users / notify_all.html.erb
<form action="send_notification_to_all" method="post">
<div><textarea rows="10" cols="100" placeholder="Enter message here"></textarea></div>
<div><input type="submit"></div>
</form>
When this form is submitted, I get 401 Unauthorized error:
Started POST "/admin/users/send_notification_to_all" for 127.0.0.1 at 2014-02-12 14:08:27 -0600
Processing by Admin::UsersController
WARNING: Can't verify CSRF token authenticity
AdminUser Load (0.8ms) SELECT "admin_users".* FROM "admin_users" WHERE "admin_users"."id" = 1 LIMIT 1
(0.3ms) BEGIN
(26.6ms) UPDATE "admin_users" SET "remember_created_at" = NULL, "updated_at" = '2014-02-12 14:08:27.394791' WHERE "admin_users"."id" = 1
(20.3ms) COMMIT
Completed 401 Unauthorized in 108.3ms
Is it possible to do what I'm trying to do, although an active administrator?
source
share