Forum: Ruby on Rails ActiveResource/ActiveRecord arg name difference

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ebb3abd946f9da9dd304fcd4b9411c46?d=identicon&s=25 Eloy Duran (alloy)
on 2007-06-01 11:59

I'm currently working on some code to support ActiveResource in
RubyCocoa with Cocoa Bindings.
I have already written (most) of the glue for ActiveRecord, so obviously
I want to keep my code DRY and reuse most of the glue code.

During this I noticed that there's a difference in argument naming
between the two.
In ActiveRecord when using the find class method you would use
:conditions to, well you know set the conditions :)
e.g.: Foo.find :all, :conditions => { :bar => 'baz' }

However in ActiveResource you are supposed to use the :params key.
e.g.: Foo.find :all, :params => { :bar => 'baz' }

I can understand how you would call them :params in ActiveResource
because they are going to be send as parameters. But I find it more
consistent if at least ActiveResource would also accept the :conditions
key. This would also allow me to use ducktyping on them, which is what
I'm doing.

So atm I've added my own workaround to ActiveResource::Base, but I could
whip up a patch for it, that would either rename the :params to
:conditions key, or simply duplicate them like in my workaround, if

class << self
  alias_method :__find__, :find
  def find(*args)
    args[1][:params] = args[1][:conditions] unless args[1].nil?

This topic is locked and can not be replied to.