rails: how do i access a method in my application controller?

前端 未结 4 1788
猫巷女王i
猫巷女王i 2021-02-06 01:09

Noob scoping issue, I imagine. :\\

class ApplicationController < ActionController::Base
  protect_from_forgery

  @locations = get_locations

  def get_locat         


        
4条回答
  •  梦毁少年i
    2021-02-06 01:43

    Even the question is quite old, you can also call your controller action anywhere just by calling:

    ApplicationController.new.get_locations
    

提交回复
热议问题