LoginSignup
1
0

More than 5 years have passed since last update.

[Ruby on railsメモ]before_actionを設定するときに、onlyなどで複数アクションを指定する。

Posted at
hoge_controller.rb
class HogeController < ApplicationController
before_action :hoge_action, only: %i[index edit_page ...]

def index
...
end

def edit_page
...
end

def ...
...
end

end

というかんじで、
%iをつけてアクションを複数指定するようでした。

Rubocopっていう自動修正ツールを使って直してたらこうなってました。

1
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
1
0