I have 2 models:
class Book < ActiveRecord::Base
has_many :book_versions
accepts_nested_attributes_for :book_versions, allow_destroy: true
validates_associated :book_versions
class BookVersion < ActiveRecord::Base
has_many :collection_items
has_many :collections, through: :collection_items
belongs_to :book
validates_presence_of :price, :isbn
Everything works fine and dandy when I go to books / new and create a book with several book versions. Validations work when I leave the price or isbn empty.
However, after creating a book with several book versions, I return to the editing form and I delete one of the prices of the existing linked version_book, and I submit the book form, it "successfully updates the book." There are two problems here:
validates_presence_of :price does not start- The version is not really being updated.
Here is a copy of part of the parameters:
"book_versions_attributes" = > { "0" = > { "name" = > "alt", "isbn" = > "," price" = > "," famis_number" = > "," famis_price" = > "," weight_in_pounds "= > " "}," 1" = > { "name" = > "bb", "isbn" = > "123123123123222222 "," price" = > "," famis_number" = > "," famis_price" = > "," weight_in_pounds "= > " 1.0 "," inventory "= > " 08 "," id "= > " 1030"},...
"", , bb book_version - .
?