list Rails controller instance variables

后端 未结 2 1634
不知归路
不知归路 2021-02-20 05:48

i was trying to list the instance variables inside a controller but came up with

irb>HomeController.instance_variable_names
=> [\"@visible_actions\", \"@in         


        
2条回答
  •  一个人的身影
    2021-02-20 05:57

    You can also call self.instance_variable_names directly from the controller code and then see them in logs.

    class ProfilesController < ApplicationController
      ...
      def update
        logger.info("List of instance vars: #{self.instance_variable_names}")
        ...
      end
    end
    

提交回复
热议问题