前提・実現したいこと
carrierwave(cludinary)を使っていて現在一度できていた複数の画像アップロードができない状態になってしまいました(色々の機能を追加中どこかでできなくなってしまいました)
発生している問題・エラーメッセージ
terminal
1tarted POST "/information" for 60.114.58.27 at 2019-10-23 15:19:09 +0000 2Cannot render console from 60.114.58.27! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255 3Processing by InformationController#create as HTML 4 Parameters: {"utf8"=>"✓", "authenticity_token"=>"b3J4JfJEXdcC4vVabTka+cKiiKOmmFmfRWYDORJJsQdQzS/RhQD+rFWiHPhoVOuP2I1R5qvdGEkFTAaDKrrA/g==", "information"=>{"title"=>"image", "description"=>"最近のです", "condition"=>"New", "image"=>[#<ActionDispatch::Http::UploadedFile:0x00007f4f81addf 5e0 @tempfile=#<Tempfile:/tmp/RackMultipart20191023-14645-1ftl8wu.JPG>, @original_filename="IMG_3010.JPG", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"information[image][]\"; filename=\"IMG_3010.JPG\"\r\nContent-Type: image/jpeg\r\n">]}, "commit"=>"Create Information"} 6 Cart Load (0.1ms) SELECT "carts".* FROM "carts" WHERE "carts"."id" = ? LIMIT ? [["id", 16], ["LIMIT", 1]] 7 ↳ app/models/concerns/current_cart.rb:5 8 User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ? [["id", 4], ["LIMIT", 1]] 9 ↳ vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.3/lib/active_record/log_subscriber.rb:98 10 (0.1ms) begin transaction 11 ↳ app/controllers/information_controller.rb:29 12 (0.0ms) rollback transaction 13 ↳ app/controllers/information_controller.rb:29 14 Rendering information/new.html.slim within layouts/application 15 Rendered information/_form.html.slim (9.1ms) 16 Rendered information/new.html.slim within layouts/application (12.7ms) 17 (0.2ms) SELECT COUNT(*) FROM "line_items" WHERE "line_items"."cart_id" = ? [["cart_id", 16]] 18 ↳ app/helpers/application_helper.rb:3 19 Rendered shared/_navbar.html.slim (7.6ms) 20#<ActiveModel::Errors:0x00007f4f819a73d8 @base=#<Information id: nil, condition: "New", title: "image", description: "最近のです", created_at: nil, updated_at: nil, image: nil, user_id: 4>, @messages={:image=>["Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: You must have ImageMagick or GraphicsMagick installed"], :title=>[], :description=>[], :condition=>[]}, @details={:image=>[{:error=>"Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: You must have ImageMagick or GraphicsMagick installed"}]}> 21Completed 200 OK in 73ms (Views: 59.6ms | ActiveRecord: 0.5ms)
該当のソースコード
ruby
1.columns 2 .column.is-8.is-centered 3 = simple_form_for @information, html: { multipart: true } do |f| 4 = f.error_notification 5 .columns 6 .field.column.is-9 7 .control 8 = f.input :title , required: true, input_html: { class: "input"}, wrapper: false, label_html: { class:"label"}, label: "Title(year,college,class)",placeholder: "2019 プログラミング大学 C言語" 9 .field 10 .control 11 = f.input :description, required: true, input_html: { class: "input" }, wrapper: false, label_html: { class:"label" } 12 .columns 13 .field.column.is-4 14 .control 15 label.label 16 | Condition 17 .control.has-icons-left 18 span.select 19 = f.input_field :condition, collection: Information::CONDITION, prompt: "Select condition" 20 span.icon.is-small.is-left 21 i.fa.fa-paint-brush 22 .field 23 .control 24 label.label 25 | Add images(パソコンだとcommandかctrを押しながら選択すると複数指定できます) 26 .file 27 label.file-label 28 = f.file_field :image, multiple: true 29 #result 30 output#list 31 hr 32 .field.is-grouped 33 .control 34 = f.button :submit, class: 'button is-warning' 35 = link_to 'Cancel', information_index_path, class:'button is-light'
ruby
1def new 2 @information = current_user.informations.build 3 end 4 5 # GET /information/1/edit 6 def edit 7 end 8 9 # POST /information 10 # POST /information.json 11 def create 12 @information = current_user.informations.build(information_params) 13 respond_to do |format| 14 if @information.save 15 format.html { redirect_to @information, notice: 'Information was successfully created.' } 16 format.json { render :show, status: :created, location: @information } 17 else 18 format.html { render :new } 19 format.json { render json: @information.errors, status: :unprocessable_entity } 20 end 21 end 22 logger.debug @information.errors.inspect 23 end
ruby
1class ImageUploader < CarrierWave::Uploader::Base 2 # Include RMagick or MiniMagick support: 3 # include CarrierWave::RMagick 4 include CarrierWave::MiniMagick 5 6 # Choose what kind of storage to use for this uploader: 7 if Rails.env.production? 8 include Cloudinary::CarrierWave 9 else 10 storage :file 11 end 12 # storage :fog 13 14 # Override the directory where uploaded files will be stored. 15 # This is a sensible default for uploaders that are meant to be mounted: 16 def store_dir 17 "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" 18 end 19 20 # Provide a default URL as a default if there hasn't been a file uploaded: 21 # def default_url(*args) 22 # # For Rails 3.1+ asset pipeline compatibility: 23 # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) 24 # 25 # "/images/fallback/" + [version_name, "default.png"].compact.join('_') 26 # end 27 28 # Process files as they are uploaded: 29 # process scale: [200, 300] 30 # 31 # def scale(width, height) 32 # # do something 33 # end 34 35 # Create different versions of your uploaded files: 36 version :thumb do 37 process resize_to_fit: [400, 300] 38 end 39 40 version :default do 41 process resize_to_fit: [800, 600] 42 end 43 44 # Add a white list of extensions which are allowed to be uploaded. 45 # For images you might use something like this: 46 def extension_whitelist 47 %w(jpg jpeg gif png) 48 end 49 50 # Override the filename of the uploaded files: 51 # Avoid using model.id or version_name here, see uploader/store.rb for details. 52 # def filename 53 # "something.jpg" if original_filename 54 # end 55 56end
試したこと
loggerを使いでバックして、原因はわかったのですが
terimanal
1brew install imagemagick 2bash: brew: command not found
のようになったので
terminal
1ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 2 To install Linuxbrew, paste at a terminal prompt: 3 sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)" 4ec2-user:~/environment/testinformation.1 (master) $ sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
hombrewをインストールして
https://gyazo.com/ff276ae67dad1e10117f6b01f2bf83ad
インストールに成功したのですが、
brew update && brew upgrade imagemagickやbrew install imagemagick とすると
bash: brew: command not foundが出てしまいます
おそらくエラーは
@details={:image=>[{:error=>"Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: You must have ImageMagick or GraphicsMagick installed"}]}> Completed 200 OK in 73ms (Views: 59.6ms | ActiveRecord: 0.5ms)
これだと思うのですが、解決方法がわかりません
回答お願いしますmm
環境はcloud9です
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/10/24 00:45
2019/10/24 02:04
2019/10/24 05:41 編集
2019/10/24 06:21 編集
2019/10/24 09:42
2019/10/24 10:37 編集
2019/10/24 10:44