How to get a model to specify a pre-requisite condition?
问题 In my model "Post.rb", I'm trying to have it only return posts if column deleted is 0. In other words, when the user deletes posts, it doesn't remove the item from the database, but rather turns deleted to 1. So if I run Post.find(:all), I want it to automatically add the condition "deleted = '0'". How do I go about doing this from my model? Thanks! 回答1: Yes, default_scope is going to be simplest method and will allow you to continue using things like Post.find(:all) without worrying about