0
Paperclip lädt keine Bilder hoch. Drucken der Ausgabe des Objekts, an das das Bild angehängt ist, um anzuzeigen, dass kein Bild hochgeladen wurde.Paperclip lädt Bilder nicht hoch, Rollback
Console:
irb(main):011:0> b = Article.find(9)
Article Load (0.5ms) SELECT "articles".* FROM "articles" WHERE "articles"."id" = ? LIMIT ? [["id", 9], ["LIMIT", 1]]
=> #<Article id: 9, title: "Rails", body: "Server", created_at: "2017-07-07 15:05:41", updated_at: "2017-07-07 15:05:41", image_
file_name: nil, image_content_type: nil, image_file_size: nil, image_updated_at: nil>
irb(main):012:0>
Log:
Command :: file -b --mime "C:/Users/addis/AppData/Local/Temp/4d3d12fcec1dd8d0eff643aa438c2b9120170708-9872-8pkize.jpg"
[paperclip] Content Type Spoof: Filename 2006-05-09_01.19.32.jpg (image/jpeg from Headers, ["image/jpeg"] from Extension), conte
nt type discovered from file command: . See documentation to allow this combination.
Command :: file -b --mime "C:/Users/addis/AppData/Local/Temp/4d3d12fcec1dd8d0eff643aa438c2b9120170708-9872-knt072.jpg"
[paperclip] Content Type Spoof: Filename 2006-05-09_01.19.32.jpg (image/jpeg from Headers, ["image/jpeg"] from Extension), conte
nt type discovered from file command: . See documentation to allow this combination.
(0.0ms) rollback transaction
Redirected to http://localhost:3000/articles/1
Completed 302 Found in 49ms (ActiveRecord: 0.5ms)
Hilfsmethode:
module ArticlesHelper
def article_params
params.require(:article).permit(:title, :body, :tag_list, :image)
end
end
Modell:
class Article < ApplicationRecord
has_many :comments
has_many :taggings
has_many :tags, through: :taggings
has_attached_file :image
validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png"]
def tag_list
self.tags.collect do |tag|
tag.name
end.join(", ")
end
def tag_list=(tags_string)
tag_names = tags_string.split(",").collect{|s| s.strip.downcase}.uniq
new_or_found_tags = tag_names.collect {|name| Tag.find_or_create_by(name: name)}
self.tags = new_or_found_tags
end
end
Wird unter Windows 10 mit Visual Code ausgeführt.
Im Anschluss daran .
Danke für die Antwort versuchen. Ich habe deine Lösung vergebens versucht. Ich habe jedoch ein Github-Problem gefunden, das mein Problem widerspiegelt: https://github.com/thoughtbot/paperclip/issues/2241 – Carrein