【发布时间】:2023-03-27 00:50:01
【问题描述】:
由于某种原因,我的自动加载器无法正常工作,我遵循了一些教程,这是我的 config\application.rb 文件的样子
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(:default, Rails.env) if defined?(Bundler)
module Quotes
class Application < Rails::Application
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
config.autoload_paths += %W(#{config.root}/lib)
我收到此错误: 未初始化的常量 ActionView::CompiledTemplates::PaginationListLinkRenderer
这是我的 lib\paginationlistlinkrenderer.rb 代码
class PaginationListLinkRenderer < WillPaginate::ViewHelpers::LinkRenderer
protected
...
...
end
这是我的 index.html.erb
<div id="img_content">
<%= render @posts%>
</div>
<%= will_paginate(@posts, :renderer => PaginationListLinkRenderer) %>
<%= link_to "New Quote", new_post_path %>
我只需要预加载这个文件,以便我的控制器能够识别它。有什么想法吗?
【问题讨论】:
标签: ruby-on-rails config loader