I'm hoping I'm doing something wrong here and someone can point me in the right direction...
I have written a method inside of one of my models, here is the code:
def self.find_by_user_id(user_id, *args)
self.find(:all, :joins => :case_map,
:conditions => ['case_maps.uer_id = ? and case_maps.case_id = cases.id', user_id],
*args)
end
I can call the code like this and it works as expected:
Case.find_by_user_id(some_user_id)
However, when this code is executed with any additional args, like this:
Case.find_by_user_id(some_user_id, :limit => 15)
I get back ALL cases. The query in my log file show that it executed this:
Case Load (0.6ms) SELECT * FROM `cases` LIMIT 15
I even put a logger.info message in that method to make sure it's the one that is executing... It seems that whenever *args is not nil, that it skips all of the conditions and joins I added to the find and just uses the *args.
Anyone see something that I'm doing wrong?