Search code examples
ruby-on-railsrubyactiverecordhas-manytable-relationships

limitations of :finder_sql


In a rails app, I using the :finder_sql option in a has_many declaration. The rails docs say that when I do this, "find_in_collection is not added." What does this mean?


Solution

  • it means that when you have a has_many relationship between to tables like:

    person has_many :books, :finder_sql

    you wont get the person.books.find* methods you normaly would have gotten. the reason for this behavior is that activerecord cant easily compose the finder_sql with the find* methods you would be using, so it cant really give you that functionality