我有一个控制器test_controller,这个控制器有一个test带有index.html.erb. 该索引可通过 /test/ 访问。
现在我想向这个控制器添加一个新的视图文件(这样我就可以访问其中设置的变量),比如说hello.html.erb/test/hello 应该可以使用它。我将它放在与testindex.htlm.erb 相同的视图文件夹中。
我当前的routes.rb条目如下所示:
scope "/test/" do
  match "/hello" => "test#hello", :controller => "test"
  match "/" => 'test#index'
end
我可以打电话/test/hello,但我无法从 test_controller 访问我的变量。为什么会这样,我该如何解决?
编辑:
test_controller看起来像这样:
class TestController < ApplicationController
  layout 'test'
  def index
    @error_logs = Error.order('creationTimestamp DESC')
  end
我想@error_logs从hello视图中访问。