-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
I have a a model called "Issue", which embeds many "Articles":
class Issue
embedded_in :publication
embeds_many :articles, :as => :articleable, :class_name => 'Article'
accepts_nested_attributes_for :articles, :allow_destroy => true, :autosave => true
end
class Article
embedded_in :articleable, polymorphic: true
accepts_nested_attributes_for :article_image, :allow_destroy => true, :autosave => true
end
Everything seems to work fine, but then I try to loop through my articles in my view and an extra article gets build with nil values:
<% issue.articles.each do |article| %>
<p><%= article.title %></p>
<% end %>
I get:
- Some value
- nil
Why in the world is this happening? When I query the exact same "Issue" in the database, then only get 1 article.