0

我有一个很大的问题,我无法弄清楚。

我试图在显示操作中生成一个页面:

# projects_controller.rb

def show
    @project = Project.find(params[:id])

    respond_to do |format|
      format.html
      format.pdf do
        render  :pdf => "#{@project.id}-#{@project.name}",
                :template => 'projects/show.pdf.erb',
                :layout => 'layouts/pdf.html.erb',
                :encoding => "utf-8",
                :show_as_html => params[:debug].present?
      end
    end
end

但是,在这个视图中,我有一些通过回形针上传的文件,当我尝试输入http://localhost:3000/projects/1.pdf例如它抛出一个错误:

Sprockets::FileOutsidePaths in Projects#show

Showing /Users/victorrodrigues/Sites/ror/linhadefrente/app/views/projects/show.pdf.erb where line #342 raised:

/system/upload/platforms/14/icon/small/revista.png?2011 isn't in paths:    /Users/victorrodrigues/Sites/ror/linhadefrente/app/assets/fontface, /Users/victorrodrigues/Sites/ror/linhadefrente/app/assets/images, /Users/victorrodrigues/Sites/ror/linhadefrente/app/assets/javascripts, /Users/victorrodrigues/Sites/ror/linhadefrente/app/assets/stylesheets, /Users/victorrodrigues/Sites/ror/linhadefrente/vendor/assets/stylesheets, /Users/victorrodrigues/.rvm/gems/ruby-1.8.7-p352@linhadefrente/gems/jquery-rails-1.0.14/vendor/assets/javascripts, /Users/victorrodrigues/Sites/ror/linhadefrente/app/assets/fontface, /Users/victorrodrigues/Sites/ror/linhadefrente/public/system

我尝试添加“系统”路径:

# application.rb
config.assets.paths << "#{Rails.root}/public/system"

但是我不知道如何解决这个问题,有人可以帮忙吗?谢谢

4

2 回答 2

0

这似乎是一个 gem 不兼容问题。

尝试gem "sprockets", "2.0"

有关详细信息,请参阅链接

于 2012-03-12T10:23:55.847 回答
0

如果您已经拥有 sprockets 2.0 或更高版本,并且您移动了包含您所引用文件的文件夹(例如,我将模板文件夹从 javascripts 移动到 assets),则可能只是缓存问题。我重新启动了我的计算机,它工作正常。

于 2013-08-01T20:04:00.237 回答