2

if I try to upload a picture message appears:

"New Content
1 error prohibited this content from being saved:

That cover has contents are not what they are reported to be "

and then shows "missing"

in Git Bash, appears:

"[Paperclip] Content Type Spoof: Filename goku.jpg (image / jpeg from Headers, [" image / jpeg "] from Extension), content type discovered from file command:. See documentation to allow this combination.
   (0.0ms) begin transaction
Command :: -b --mime file "C: /Users/xxxxxx/AppData/Local/Temp/1151fe66500e3084eef890162322a11020170115-9100-1xumnlr.jpg"
[Paperclip] Content Type Spoof: Filename juegos-vestir-goku.jpg (image / jpeg from Headers, [ "image / jpeg"] from Extension), content type discovered from file command:. See documentation to allow this combination.
   (0.0ms) rollback transaction
  Rendering contents / new.html.erb Within layouts / application
  Rendered contents / _form.html.erb (4.0ms)
  Rendered contents / new.html.erb Within layouts / application (30.0ms)
  Rendered layouts / _header2.html.erb (2.0ms)
  Rendered layouts / _footer.html.erb (0.0ms)
Completed 200 OK in 627ms (Views: 511.2ms | ActiveRecord: 0.0ms) "

Also when I installed paperclip appeared the message:

"Post-install message from paperclip:
##################################################
# NOTES FOR UPGRADING FROM 4.3.0 OR EARLIER #
##################################################

Paperclip is now compatible with aws-sdk> = 2.0.0.

If you are using S3 storage, aws-sdk> = 2.0.0 requires you to make a few small
changes:

* You must September the `s3_region`
* If you are Explicitly setting permissions anywhere, such as in an initializer,
  notes That the format of the permissions changed from using an underscore to
  using a hyphen. For example, `: public_read` needs to be changed to
  `Public-read`.

For a walkthrough of upgrading from 4 to 5 and aws-sdk> = 2.0 you can watch
http://rubythursday.com/episodes/ruby-snack-27-upgrade-paperclip-and-aws-sdk-in-prep-for-rails-5 "

perform operations to install paperclip:

- Downloaded magemagick for windows
- Insert in Gemfile gem "paperclip", "~> 5.0.0"
- Bundle install

- In the app >> model >> content.rb I entered:
has_attached_file: cover, styles {medium: "300x>" thumb "100x>"}
validates_attachment_content_type: cover, content_type: /\Aimage\/.*\z/

- Rails generate paperclip content cover

- Rake db: migrate

- I added to my code in the app> views> contents> _form,:
 <%= form_for @content, html: { multipart: true } do |f| %>

<Div class = "field">
    <% = F.label: cover%>
    <% = F.file_field: cover%>
  </ Div>

- App> controllers> content, I entered:
def content_params
      params.require (: content) .permit (: title: description: price,: cover)
end

- App> views> content> show I entered:
<% = @ Image_tag content.cover.url (: thumb)%>

- App> views> content> index> I entered:
<Td> <% = image_tag content.cover.url (: medium)%> </ td>

Versions used:

-Win10 x64
-ruby 2.3.3p222
-Rails 5.0.1
-paperclip 5.1.0

Tests carried out, but not decisive:

  • Added in app> model> content.rb:

    :default_url => "/images/:style/missing.png"

  • Added in config / environments / development.rb:

    Paperclip.options [: command_path] = "/ usr / local / bin /"

    Paperclip.options [: command_path] = 'C: \ Program Files (x86) \ GnuWin32 \ bin

  • Added in - Added in app> model> content.rb:

    Paperclip.options [: command_path] = 'C: \ Program Files (x86) \ GnuWin32 \ bin; C: \ Program Files \ ImageMagick-7.0.4-Q16 '

    Paperclip.options [: swallow_stderr] = false

neotrojan
  • 69
  • 7

0 Answers0