Merge pull request #13559 from JuanitoFatas/action-controller
[ci skip] Add missing flash message in block filter example.
This commit is contained in:
commit
224d3a69ac
@ -665,7 +665,10 @@ The first is to use a block directly with the *_action methods. The block receiv
|
||||
```ruby
|
||||
class ApplicationController < ActionController::Base
|
||||
before_action do |controller|
|
||||
redirect_to new_login_url unless controller.send(:logged_in?)
|
||||
unless controller.send(:logged_in?)
|
||||
flash[:error] = "You must be logged in to access this section"
|
||||
redirect_to new_login_url
|
||||
end
|
||||
end
|
||||
end
|
||||
```
|
||||
@ -682,7 +685,7 @@ end
|
||||
class LoginFilter
|
||||
def self.filter(controller)
|
||||
unless controller.send(:logged_in?)
|
||||
controller.flash[:error] = "You must be logged in"
|
||||
controller.flash[:error] = "You must be logged in to access this section"
|
||||
controller.redirect_to controller.new_login_url
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user