Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 是否可以使用活动管理员呈现普通模板html.erb模板?_Ruby On Rails 3_Layout_Activeadmin - Fatal编程技术网

Ruby on rails 3 是否可以使用活动管理员呈现普通模板html.erb模板?

Ruby on rails 3 是否可以使用活动管理员呈现普通模板html.erb模板?,ruby-on-rails-3,layout,activeadmin,Ruby On Rails 3,Layout,Activeadmin,我的管理员中有一个自定义页面,该页面由活动管理员生成: 在app/admin/stats.rb中: ActiveAdmin.register_page 'Stats' do controller do def index @foo = 'bar' end end end <h1> Admin stats</h1> <p><%= @foo %></p> ActiveAdmin.register_

我的管理员中有一个自定义页面,该页面由活动管理员生成:

在app/admin/stats.rb中:

ActiveAdmin.register_page 'Stats' do

  controller do

    def index
      @foo = 'bar'
    end
  end
end
<h1> Admin stats</h1>
<p><%= @foo %></p>
ActiveAdmin.register_page 'Stats' do

  content do
    render 'index'
  end

  controller do
    def index
      @foo = 'bar'
    end
  end

end
在app/views/admin/stats/index.html.erb中:

ActiveAdmin.register_page 'Stats' do

  controller do

    def index
      @foo = 'bar'
    end
  end
end
<h1> Admin stats</h1>
<p><%= @foo %></p>
ActiveAdmin.register_page 'Stats' do

  content do
    render 'index'
  end

  controller do
    def index
      @foo = 'bar'
    end
  end

end

但这并没有改变任何事情。仍然是我的统计页面没有布局。有什么想法吗?

这是一种方法:

在app/admin/stats.rb中:

ActiveAdmin.register_page 'Stats' do

  controller do

    def index
      @foo = 'bar'
    end
  end
end
<h1> Admin stats</h1>
<p><%= @foo %></p>
ActiveAdmin.register_page 'Stats' do

  content do
    render 'index'
  end

  controller do
    def index
      @foo = 'bar'
    end
  end

end
并将
app/views/admin/stats/index.html.erb
重命名为
app/views/admin/stats/_index.html.erb
(请注意

而且效果很好

据我所知,如果
views/admin/stats
中存在
index.html.erb
,则不会调用
内容
块。如果
index.html.erb
被重命名为其他内容,那么我们进入内容块,然后布局呈现被称为