How to call methods defined in ApplicationController in models

后端 未结 2 1293
一向
一向 2021-01-11 11:03

I have defined method in ApplicationController

class ApplicationController < ActionController::Base
   helper_method :get_active_gateway
   def get_active         


        
相关标签:
2条回答
  • 2021-01-11 11:14

    Why would you need such thing? The model should not know about its controllers. Maybe a redesign of your system will be more appropriate in this case.

    Here is a link to similar thread.

    0 讨论(0)
  • 2021-01-11 11:18

    As a design choice, its not recommended to call controller helpers from your models.

    You can just simply pass the required details to your model methods as arguments.

    
    def transfer(active_gateway)
      active = active_gateway
    end
    
    0 讨论(0)
提交回复
热议问题