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
You can also do it with your terminal with the command line gem list rails --remote --all | grep "^rails ". I you want to install rails on another version of ruby, you need to switch version of ruby and re-install version of rails. You can check list gems to see if you installed succesfullly:
Before making the big jump, make sure to upgrade to Rails 5.2.3 and that everything is running as expected at this version. If your Rails version is 5.2, it would be a painless process. That was the case for one of my apps, but the other app was at Rails 5.0.6.
The easiest way to configure CORS on your Rails app is to use rack-cors gem. You can install it like any other gem, by executing: Next, you need to provide the configuration for the gem. You need to inform Rails which origin it should allow. To do that, you need to create a new initializer for your application.
In the case of a monolith Ruby on Rails application, both front end and back end are at the same origin. But when you use the Rails application only as an API, then you’ll have another application running as a front end. That’s when you’ll need to configure Rails to allow that front-end application to connect.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With