Search code examples
ruby-on-railsmultipart

How add multipart to form helper (Carrierwave)


I try to add multipart upload for Carrierwave in my form, but I have two controllers(admin_posts and posts) in one model(post).So I do not understand how to specify this

_form.html.haml

= form_for [:admin, @post] do |f|
  = f.fields_for :photos do |photo_fields|
    = photo_fields.file_field :image
  = f.text_field :title, class: "form-control", placeholder: "Title"
  = f.text_area :body, rows: 12, class: "form-control", placeholder: "Body"
  .pull-right
    = f.submit "Send", class: "btn btn-success"

how fix?

sorry for my English


Solution

  • Try this

    = form_for [:admin, @post], url: your_action_path(@post), html: { multipart: true } do |f|