ruby on rails - Carrierwave not saving the file on disk -


Everyone please help me with carrier service and train 4.

Model:

  class media items & lt; ActiveRecord :: Base mount_uploader: media_item, MediaItemUploader end  

schema:

  create_table "media_items", force: true do | T | T.string "file" t.text "description", default: "", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: wrong end  

Uploader:

  Class Media ItemMaplayer & lt; Career carrier :: Uploader :: Base Def store_dir "public /" and  

Controller:

  Class MediaTime Controller & lt; ApplicationController def can be created @ mediaItem = MediaItem.net (media_item_params) response_to do format | If @media_item. Save format.html {redirect_to @media_item, notice: 'Media item was created successfully.' } And format.html {render: new} end and end  

form:

  = form_for, for media_item: html = & gt; {: Multipurpose = & gt; True} what? F | .field = f.label: description = f.text_field: description .field = f.label: file = f.file_field: file .actions = f.submit 'save'  

The problem is That the uploaded file does not appear in the specified DIR and "media_item.media_item_url" returns an empty string in a view. However, it has been re-entered in DB:

  choose the file, details from media_items; # & Lt; ActionDispatch :: Http :: UploadedFile: 0xba672374 & gt; |  

My mistake

Instead

Pre mount_uploader: media_item, mediaItemUploader must be

  mount_uploader: file, media item installer  

As the "file" field name is in DB, "media_item" does not


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -