No implicit conversion of ActiveSupport :: SafeBuffer to Integer

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' 

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

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

Has anyone come across something like this?

0
source share
2 answers

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

0
source

No FormHelper has_many .

It seems you want to create fields for the has_many association. Helper for this 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 have not tried. I do not know s3_file_field.

If you want to add / remove several attachments: there is a good Railscast on this topic, look at the gem .

+1
source

Source: https://habr.com/ru/post/912741/


All Articles