我正在运行Rails 3.2.8并构建了一个链接到自定义CSS文件和图像的应用程序。 自定义CSS文件放在我的Assets / stylesheets文件夹中,图像放在Assets / images中。 出于某种原因,当我将应用程序推送到Heroku时,不会加载CSS和图像。 该应用程序生成一个manifest.yml文件,其中包含所有图像和CSS文件。 CSS文件是Twitter Bootstrap的自定义版本: http : //twitter.github.com/bootstrap/index.html 希望你们能提前帮助和感谢!
我正在使用Carrierwave上传图片,我的应用程序现在正在Heroku上。 除非我将新提交推送到heroku,否则图像上传成功。 当推送新提交时,我在推送之前上传的图像似乎被删除。有谁知道背后的原因以及如何解决这个问题? 更新:问题变成了, 在没有像Amazon EC3这样的存储服务器的Heroku上使用carrierwave 。 Heroku不会将文件保存在公共文件夹中,默认情况下载波上传。 应用程序/上传/ image_uploader.rb: def store_dir “uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}” end 并且您需要将其更改为tmp文件夹中的某个位置,以便在每次提交后保留图像文件。 我试着改变它 “#{Rails.root}/tmp/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}” 但它不起作用。 我检查了我的本地环境,图像成功存储在正确的位置。 所以我想如果我只是将路线设置到正确的位置,这可能会起作用。 有人可以帮我吗?
我在本地使用的heroku网站的背景图片有问题 background-image: url(‘background_stripe.png’); 但是在部署时文件被破坏了 我试过用过 background-image: image-url(‘background_stripe.png’); background-image: url(image-url(‘background_stripe.png’)); background-image: url(image_url(‘background_stripe.png’)); 没有一个在本地或在heroku上工作。 使用bash我发现heroku已将图像文件命名为background_stripe.png,但它没有哈希值,而且它的图像已损坏
我最近将我的Rails更新为3.1。 这是我添加的部分: 这使得/assets/logo_symbol.png呈现在开发环境中完美无缺。 但是,当我将代码推送到heroku上的生产时,它会显示一个损坏的图像,其中包含url: assets/logo_symbol-135ddc8db2c9b59f032bed7db520137a.png 。 我猜这个新名字是出于一些优化的原因。 然而,值得注意的是,当我在生产中转到assets/logo_symbol-135ddc8db2c9b59f032bed7db520137a.pngurl时,我看到一个空白页面,但是当我将该url更改为任意内容时,例如向其添加数字时,它会显示一个页面而不是找到。 很明显,它正在那个url上找到一些东西。 当我直接在production / heroku上访问/assets/logo_symbol.png时,它还会显示一个空白页面。 如果这是任何帮助,heroku不会在我推送代码时成功预编译,并且heroku的文档说当前没有解决该问题的方法。 任何帮助将非常感谢。 我的猜测是它与某些与环境相关的配置有关。 我附上了我的application.rb,development.rb和production.rb文件的内容 这是我的production.rb文件的内容 # Settings specified here will take precedence over those in config/application.rb # In the development environment your application’s code is reloaded on # every request. This slows down response time but is perfect for development # since you […]
我在Heroku上部署了一个应用程序,我在Ruby on Rails上编写了这个应用程序。 这是一个电影评论应用程序。 我可以将计算机上传的图像上传到网络应用程序。 其他一切都按照我的期望运作。 一天后图像消失。 我的要求是让图像继续渲染。 我正在使用来自rails的Paperclip gem。 这仅发生在已部署的版本上,而不是在localhost上。
我非常坚持这个问题,希望你们能帮助我。 我想要实现的是点击链接,按钮或图像,这似乎更简单,我使用toDataURL将canvas转换为图像。 之后,将打开包含此图像的新窗口。 如何使用ruby on rails将从toDataURL生成的数据url传递到新窗口? 提前致谢。
我已经通过MacPorts在OSX上安装了RMagick,可以通过运行’gem server’来查看它。 但是,当我尝试将其包含在我的脚本中时使用 require ‘rubygems’ require ‘RMagick’ 它崩溃时出现以下错误消息 ./RMagick.rb:4:in `show_info’: uninitialized constant Magick (NameError) from ./RMagick.rb:24 from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’ from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require’ from ./rmagick.rb:1 from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’ from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require’ from get_pixels.rb:2 谁能告诉我我做错了什么?
当current_user单击pin时,该图像如何保存到current_user ? 按钮: 产出 : pry(main)> Inspiration.first id: 1, user_id: 1, image_file_name: “choose-optimism.png”, image_content_type: “image/png”, image_file_size: 230082, pry(main)> Inspiration.last id: 2, # Creating the issue of the route error & image not rendering user_id: 2, image_file_name: “choose-optimism.png”, image_content_type: “image/png”, image_file_size: 230082, 固定图像的id不同,给出错误: No route matches [GET] “/system/inspirations/images/000/000/002/medium/choose-optimism.png” 工作图像有001 : /system/inspirations/images/000/000/001/medium/choose-optimism.png?1478840469 解决此问题的最佳方法是什么,以便我可以继续传递不同的ID,但使用相同的图像? 调节器 @inspirations = @user.inspirations […]
我需要一些帮助。 我使用rails 5和carrierwave上传图像。 我遇到的问题是图像被保存但不会显示,我得到一个无路由匹配GET …..我将图像存储在Rails.root的uploads文件夹中,因为我不希望它们保存在公共场所DIR。 image_uploader.rb def store_dir “uploads/#{model.user_id}/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}” end carrier_wave.rb require ‘carrierwave/orm/activerecord’ require ‘carrierwave’ CarrierWave.configure do |config| config.root = Rails.root end 这是我在日志中收到的错误: Started GET “/uploads/2/uitem/image/26/A_penrose-small.jpg” for ::1 at 2016-10-29 16:06:27 +0200 ActionController::RoutingError (No route matches [GET] “/uploads/2/uitem/image/26/A_penrose-small.jpg”): 非常感谢任何帮助,我一直在搜索,无法找到解决方案。 谢谢
我正在遍历在外部站点托管的一系列URL图像字符串。 它看起来像这样: def get_image_urls image_url_array.each do |image_url| puts image_tag image_url end end 这将返回外部站点上托管的图像的URL。 问题是,其中一些图像可能会被破坏(404)。 例如: get_image_urls # These would return image_tags, but for brevity… => “http://sofzh.miximages.com/ruby-on-rails/1.jpg” “http://sofzh.miximages.com/ruby-on-rails/2.jpg” “http://sofzh.miximages.com/ruby-on-rails/3.jpg” # <– (Broken: 404) "http://sofzh.miximages.com/ruby-on-rails/4.jpg" "http://sofzh.miximages.com/ruby-on-rails/5.jpg" # <– (Broken: 404) 我要做的是将损坏图像的URL字符串替换为我自己网站上托管的“缺失”图像。 所以使用上面的例子,3.jpg和5.jpg被打破了,我想要返回这样的东西: get_image_urls # These would return image_tags, but for brevity… => “http://sofzh.miximages.com/ruby-on-rails/1.jpg” “http://sofzh.miximages.com/ruby-on-rails/2.jpg” “http://mysite.com/images/missing.png” “http://sofzh.miximages.com/ruby-on-rails/4.jpg” “http://mysite.com/images/missing.png” […]