no implicit conversion of ActiveSupport::SafeBuffer into Integer

天涯浪子 提交于 2019-12-12 04:51:52

问题


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?


回答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.




回答2:


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



来源:https://stackoverflow.com/questions/26996966/no-implicit-conversion-of-activesupportsafebuffer-into-integer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!