没有将ActiveSupport :: SafeBuffer隐式转换为Integer

时间:2014-11-18 14:41:49

标签: ruby-on-rails activeadmin partial formtastic

这是我的部分_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'

问题是我遇到错误no implicit conversion of ActiveSupport::SafeBuffer into Integer指向此=f.has_many :attachments do |a|行。

如果我删除builder: ActiveAdmin::FormBuilder,则会收到undefined method 'has_many' for #<Formtastic::FormBuilder:0x007fda897dfc88>错误。

任何人都有这样的事情吗?

2 个答案:

答案 0 :(得分:1)

没有FormHelper has_many

看来,您想要为has_many关联创建字段。帮助者是fields_for 尝试:

= 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'

我没有尝试过。我不知道s3_file_field。

如果您想添加/删除多个附件:此主题有一个很好的Railscast,请查看gem cocoon

答案 1 :(得分:0)

事实上,正如稍后发生的那样,解决方案只是运行bundle update activeadmin