rails access view name inside partial

后端 未结 4 1121
梦谈多话
梦谈多话 2021-02-19 12:57

I have a partial that I am using in different pages. I want to conditionally hide a certain div inside the partial based on the view that is rendering it.

I was thinkin

4条回答
  •  暖寄归人
    2021-02-19 13:13

    you can get the name of the currently-rendering partial from within a Helper method with the following :

    controller.view_context.view_renderer.instance_variable_get('@_partial_renderer').instance_values['path']
    

提交回复
热议问题