2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ActiveAdminで独自Actionを作る

Last updated at Posted at 2018-09-17

ActiveAdminでとあるリソースに対して独自のActionを定義したいときに見る

定義

UserにActionを定義したいとき

app/admin/users.rb
member_action :new_action, method: :post do
    # なんらかのresouceに対する操作
  end
end

method:は適宜

定義したActionを呼び出す項目を作る

action: をHashで渡さないとmethod:がgetメソッドのparamsに化ける。
https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to

app/admin/users.rb
action_item :view, only: :show do
  link_to 'Action', { action: :new_action }, method: :post
end
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?