Rails.logger.info(self.instance_variables)
Rails.logger.info(binding.eval("local_variables"))
With the above code, you can output instance variables and local variables as INFO logs. When you want to check the big picture and variables that can be used in the project you see for the first time.
Whether it's a Rails controller or a view file, You can use the value of self.instance_variables in the form of the instance variable @var. The binding object is according to here
Objects that represent environmental information such as variables and methods
That thing. You can get local variables by taking "local_variables" as an argument with the eval method.
ruby-lang.org: Object section ruby-lang.org: binding section UK MILK: Explanation of binding
Recommended Posts