no implicit conversion of ActiveSupport::SafeBuffer into Integer
Asked Answered
V

2

0

Here is my partial _new_post.html.haml:

= semantic_form_for Post.new, as: :post, url: client_panel_discussion_posts_path(resource), html: { data: { discussion_posts_url: client_panel_active_submission_discussion_url(resource.client_application, id: resource.slug) }, multipart: true}, builder: ActiveAdmin::FormBuilder, remote: true, method: :post do |f|
  =f.inputs do
    =f.input :body
    =f.has_many :attachments do |a|
      =a.input :s3_url, as: :hidden, input_html: { class: "s3_url" }
      =a.s3_file_field :attachment, as: :file, class: 'js-s3_file_field'

Problem is that I get following error: no implicit conversion of ActiveSupport::SafeBuffer into Integer pointing to this =f.has_many :attachments do |a| line.

If I remove builder: ActiveAdmin::FormBuilder I get undefined method 'has_many' for #<Formtastic::FormBuilder:0x007fda897dfc88> error.

Anyone faced something like this?

Vulturine answered 18/11, 2014 at 14:41 Comment(0)
V
0

In fact, as it occurred later, the solution was simply to run bundle update activeadmin.

Vulturine answered 15/1, 2015 at 11:36 Comment(0)
I
1

There is no FormHelper has_many.

It seems, you want to create fields for a has_many association. The Helper for that is fields_for.
Try:

= semantic_form_for @post, as: :post, url: client_panel_discussion_posts_path(resource), html: { data: { discussion_posts_url: client_panel_active_submission_discussion_url(resource.client_application, id: resource.slug) }, multipart: true}, builder: ActiveAdmin::FormBuilder, remote: true, method: :post do |f|
  =f.inputs do
    =f.input :body
    =f.fields_for :attachments do |a|
      =a.input :s3_url, as: :hidden, input_html: { class: "s3_url" }
      =a.s3_file_field :attachment, as: :file, class: 'js-s3_file_field'

I didn't try it. I don`t know s3_file_field.

If you want to add/delete several attachments: there is a good Railscast on this topic an have a look at the gem cocoon.

Ivett answered 18/11, 2014 at 14:56 Comment(5)
hey, thx for reply!! It was silly of mine - I've tried fields for, not fields_for :D Still it is not working, it doesnt show anything, doesnt add any html - as if no code were written.Vulturine
do you have any attachments already? field_for doesn't show field for new attachments (unless you manually built a new attachment on Post.new)Ivett
Yea, I've got it in my new action def show post = Post.new post.attachments.build end (nevermind it's in show, it's because I build it in different controller) I actually want to allow user to add attachments to postVulturine
thank you so much! I am about to accept/upvote the answer, because I can now see the button to attach the files, last important thing - how can I actually allow user to attach more then one attachment?Vulturine
I added two links to my answer covering this topic.Ivett
V
0

In fact, as it occurred later, the solution was simply to run bundle update activeadmin.

Vulturine answered 15/1, 2015 at 11:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.