我有一个很大的问题,我无法弄明白。
我试图在节目动作中生成一个页面:
# 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"
但我不知道如何解决这个问题,有人可以提供帮助吗? 感谢
答案 0 :(得分:0)
答案 1 :(得分:0)
如果你已经有sprockets 2.0或更高版本,并且移动了包含你所指的文件的文件夹(例如我将我的模板文件夹从javascripts移动到资源),那么它可能只是一个缓存问题。我重启了电脑,工作正常。