Ruby on rails 3 Can';t从Rails引擎中的应用程序控制器访问my helper中的变量
我创建了一个扩展Rails引擎的gem。我使用的是Rails 4。一切正常,除了我无法从助手访问应用程序控制器中的实例变量。这是我的代码…我做错了什么 app/controllers/application\u controller.rbRuby on rails 3 Can';t从Rails引擎中的应用程序控制器访问my helper中的变量,ruby-on-rails-3,ruby-on-rails-4,gem,rails-engines,Ruby On Rails 3,Ruby On Rails 4,Gem,Rails Engines,我创建了一个扩展Rails引擎的gem。我使用的是Rails 4。一切正常,除了我无法从助手访问应用程序控制器中的实例变量。这是我的代码…我做错了什么 app/controllers/application\u controller.rb class ApplicationController < ActionController::Base protect_from_forgery with: :exception def get_context @va
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def get_context
@variable = "variable"
end
end
module EvaluateHelper
def app_name
@variable #=> nothing here
end
end
require "rails"
require "evaluate/version"
module Evaluate
VERSION = "0.0.1"
class Engine < ::Rails::Engine
end
end
lib/evaluate/version.rb
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def get_context
@variable = "variable"
end
end
module EvaluateHelper
def app_name
@variable #=> nothing here
end
end
require "rails"
require "evaluate/version"
module Evaluate
VERSION = "0.0.1"
class Engine < ::Rails::Engine
end
end
为什么没有答案?