0

ネストされたフォームで link_to_add リンクをクリックすると、「Uncaught Error: Syntax error, unrecognized expression: #[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