Rubyファイル内でアプリケーションコントローラーメソッドを呼び出すにはどうすればよいですか? 従来の MVC アーキテクチャを使用できません。
ありがとう!
Rubyファイル内でアプリケーションコントローラーメソッドを呼び出すにはどうすればよいですか? 従来の MVC アーキテクチャを使用できません。
ありがとう!
If the method is meant to be called from both the application controller and some other ruby file, then you need to move that method to another file, probably a Plain Old Ruby Object (PORO). Then, require that file from your controller and from whatever other file needs to use it.
It's a good idea to only have controller-related logic in controllers. Since you're calling this method from something besides a controller, it must not be strictly controller-related logic, so this is the perfect opportunity to move it.