0

单击嵌套表单中的 link_to_add 链接时,我收到“未捕获的错误:语法错误,无法识别的表达式:#[object Object]_fields_blueprint”。

form.html.erb

<%= simple_nested_form_for(@post, :html => {:multipart => true}) do |f| %>
  <%= f.error_notification %>

  <div class="form-inputs">
    <%= f.input :title %>
    <%= f.input :content %>
    <%= f.simple_fields_for :news_photos do |p| %>
      <%= p.input :image %>
      <%= p.input :caption %>
    <% end %>
    <%= f.link_to_add "Add Photo", :news_photos %>
  </div>

  <div class="form-actions">
    <%= f.button :submit %>
  </div>
<% end %>

post.rb

class Post < ActiveRecord::Base
  has_many :news_photos, :dependent => :destroy
  accepts_nested_attributes_for :news_photos, :allow_destroy => true
end

news_photo.rb

class NewsPhoto < ActiveRecord::Base
  belongs_to :post
  has_attached_file :image, :styles => {:featured => "299x185>", :main => "631x298>", :thumb => "104x106>"}, :default_url => "/images/empty.png"
end

有任何想法吗?

4

0 回答 0