https://haml2erb.org haml to html
在實作時出現錯誤
Please help with the Paperclips!
First things first, as per the docs, you’ll need imagemagick running on your development computer. Set it up as per the instructions here.
--------------------------------------------------------------------------------
Set the MAGICK_HOME environment variable to the path where you extracted the ImageMagick files. For example:
export MAGICK_HOME="$HOME/ImageMagick-7.0.2"
If the bin subdirectory of the extracted package is not already in your executable search path, add it to your PATH environment variable. For example:
export PATH="$MAGICK_HOME/bin:$PATH"
Set the DYLD_LIBRARY_PATH environment variable:
export DYLD_LIBRARY_PATH="$MAGICK_HOME/lib/"
Finally, to verify ImageMagick is working properly, type the following on the command line:
magick logo: logo.gifidentify logo.gifdisplay logo.gif
--------------------------------------------------------------------------------
後來忽略,回到 https://www.devwalks.com/lets-build-instagram-in-rails-part-1/
Next we’ll add the paperclip gem to our gemfile as per their docs.
gem 'paperclip', '~> 4.2' #at the writing of this post
Read the next bit of the docs, what does it ask you to do now?
bundle install
再上傳檔案時發生
Photo Could not run the identify command. Please install ImageMagick.
解決,
You need to change the files
production.rb
and development.rb
which are in:
config/environments:
# Paperclip config:
Paperclip.options[:image_magick_path] = "/opt/ImageMagick/bin"
Paperclip.options[:command_path] = "/opt/ImageMagick/bin"
Just add those two lines just before the last line and restart the server.
In MacOSX system, if you are using another location, just put the right PATH there.
我的路徑是 :
Paperclip.options[:command_path] = "/Users/QJpioneer/ImageMagick-7.0.1/bin/" Paperclip.options[:image_magick_path] = "/Users/QJpioneer/ImageMagick-7.0.1/bin/"
上傳檔案後
似乎沒有吃進去圖檔.....
用rails c 進去看
看伺服器端
Started POST "/posts" for ::1 at 2016-07-13 07:15:07 +0800Processing by PostsController#create as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"Qyu7WWiAJR5AV0MuzIEzfbXvoeYVDxcla+wGaWm92bwA9QScqJf+hZ3aJkvP1OutO5W3+Lgbh4AjsCtDKukVKg==", "post"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x007fc281b10ff8 @tempfile=#<Tempfile:/var/folders/js/038lfs452n362y3xc7phyz100000gn/T/RackMultipart20160713-54694-1qdykz.jpg>, @original_filename="Country life.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"post[image]\"; filename=\"Country life.jpg\"\r\nContent-Type: image/jpeg\r\n">, "caption"=>"123"}, "commit"=>"Create Post"}Command :: PATH=/Users/QJpioneer/ImageMagick-7.0.1/bin/:$PATH; file -b --mime '/var/folders/js/038lfs452n362y3xc7phyz100000gn/T/993316952cab27089c21a4f6fdd5299020160713-54694-1fsypu2.jpg'Command :: PATH=/Users/QJpioneer/ImageMagick-7.0.1/bin/:$PATH; identify -format '%wx%h,%[exif:orientation]' '/var/folders/js/038lfs452n362y3xc7phyz100000gn/T/b2aa763204471d9d58ed3488ce58a26b20160713-54694-1129s9z.jpg[0]' 2>/dev/null[paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError> (0.1ms) begin transactionCommand :: PATH=/Users/QJpioneer/ImageMagick-7.0.1/bin/:$PATH; file -b --mime '/var/folders/js/038lfs452n362y3xc7phyz100000gn/T/993316952cab27089c21a4f6fdd5299020160713-54694-1e7exev.jpg' (0.1ms) rollback transactionRedirected to http://localhost:3000/postsCompleted 302 Found in 143ms (ActiveRecord: 0.3ms)Started GET "/posts" for ::1 at 2016-07-13 07:15:08 +0800Processing by PostsController#index as HTML Post Load (0.2ms) SELECT "posts".* FROM "posts" Rendered posts/index.html.erb within layouts/application (1.1ms)Completed 200 OK in 32ms (Views: 31.3ms | ActiveRecord: 0.2ms)
沒有留言:
張貼留言