subcategories_attributes
are sent correctly within your params
hash BUT content
attribute is missing in them.
"subcategories_attributes"=>{"1398706662184"=>{"name"=>"TS1",
"_destroy"=>"false"}, "1398706664804"=>{"name"=>"TS2", "_destroy"=>"false"}}
Notice there is no content
key passed.
So, all the subcategories records passed in subcategories_attributes
are REJECTED due to the condition you specified in Category
model:
accepts_nested_attributes_for :subcategories, :reject_if => lambda {|a|
a[:content].blank?}
Notice :reject_if => lambda {|a| a[:content].blank?}
part above, this will reject all the records for which content
is missing.
UPDATE
when I go to my edit action, the fields don't show up, despite being added to the database as intended (and showing up as such in other forms).
Set a variable in edit
and new
actions as below:
def new
@category = Category.new
@subcategories = @category.subcategories.build ## Added
end
def edit
@subcategories = @category.subcategories ## Added
end
Update the fields_for
in edit
form as below:
<%= f.fields_for :subcategories, @subcategories do |builder|%>