Reputation: 1711
in application_controller.rb:4
class ApplicationController < ActionController::Base
before_action :prepare_meta_tags, if: "request.get?"
Rails 5.1 WARNING
DEPRECATION WARNING: Passing string to be evaluated in :if and :unless conditional options is deprecated and will be removed in Rails 5.2 without replacement. Pass a symbol for an instance method, or a lambda, proc or block, instead. (called from <class:ApplicationController> at MYSITE/app/controllers/application_controller.rb:4)
Question:
I have if and unless all over in my project. Need advice. Thanks
Upvotes: 19
Views: 5483
Reputation: 3412
First of all, don't worry they are not deprecating :if and :unless. They are deprecating passing a string to it.
Using lambda instead is way better in this case
class ApplicationController < ActionController::Base
before_action :prepare_meta_tags, if: -> { request.get? }
...
end
Upvotes: 43