Ruby on rails 使用回形针时不显示图像

Ruby on rails 使用回形针时不显示图像,ruby-on-rails,ruby-on-rails-3,Ruby On Rails,Ruby On Rails 3,这个问题,我一直试图解决的帮助下,堆栈超过网站。但不幸的是我不能这么做。所以我决定求助于他人 我尝试了所有这些链接来解决这个问题。但它们都不起作用 http://stackoverflow.com/questions/25934465/rails-paperclip-not-showing-image http://stackoverflow.com/questions/9170335/paperclip-images-not-displaying-in-rails-app

这个问题,我一直试图解决的帮助下,堆栈超过网站。但不幸的是我不能这么做。所以我决定求助于他人

我尝试了所有这些链接来解决这个问题。但它们都不起作用

    http://stackoverflow.com/questions/25934465/rails-paperclip-not-showing-image
    http://stackoverflow.com/questions/9170335/paperclip-images-not-displaying-in-rails-app
    http://stackoverflow.com/questions/23971226/rails-image-not-showing-up-with-paperclip
    http://stackoverflow.com/questions/31348628/paperclip-not-showing-image-even-though-url-images-in-correct-places
    http://stackoverflow.com/questions/7425001/specifying-missing-png-in-paperclip
    http://stackoverflow.com/questions/25249252/paperclip-where-to-place-the-
    missing-png-default-image
    http://stackoverflow.com/questions/38734116/ruby-paperclip-how-to-get-missing-png-to-work
现在我的问题是它总是显示一个正方形的图像,上面写着失踪

下面是我的代码

Recipe.rb

 class Recipe < ApplicationRecord

        has_attached_file :image, styles: { medium:  "400x400#" },
       :path => ":rails_root/public/system/:attachment/:id/:style/:filename",
       :url => "/system/:attachment/:id/:style/:filename"

      validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/

      end 
菜谱的new.html.haml

= image_tag @recipe.image.url(:medium, class: "recipe_image")
= simple_form_for @recipe, html: { multipart: true } do |f|
  - if @recipe.errors.any?
    #errors
      %p
        = @recipe.errors.count
        Prevented this recipe froms saving
      %ul
        - @recipe.errors.full_messages.each do |msg|
          %li= msg
  .panel-body
    = f.input :title, input_html: { class: 'form-control' }
    = f.input :description, input_html: { class: 'form-control' }
    = f.input :image, input_html: { class: 'form-control' }

    = f.button :submit, class: "btn btn-primary"

同样的问题已经有一段时间了,但现在我自己解决了

我所做的:

查看站点文件夹以查看图像的保存位置。i、 e.我的保存路径与我的post.rb文件中显示的路径不同。 这是我唯一的建议。右键单击并检查损坏图像上的元素,然后进行比较


我做了相应的调整,现在效果很好:)

这篇文章的标题并没有描述手头的实际问题。也应该在你作为第二个参数给班级的问题的顶部描述要解决的问题。应该是“=image_tag@recipe.image.url(:medium),class:“recipe image”?@KevinEtore,尝试过但没有工作。该图像是否确实保存在数据库中?不,它没有保存到数据库中。我还将:图像添加到我的配方参数中。但是我的配方表中的列有image\u file\u名称。但是您的图像是否未保存在站点路径中?您可以诊断出问题所在