Monthly Archives: January 2012

How to check if object can be destroyed if it has dependent: restrict associations

Rails provides several handy options for specifying how to deal with associated models upon deletion, for example: class Blog has_many :posts, :dependent => :destroy end The destroy value for the dependent option will call the destroy method for every post in the blog when the blog itself is destroyed. Other options are delete or nullify, … more

Posted in Blogs | Tagged |