Plugin help

I am trying to do an active record find method. When I call it from
the console it says method_missing.

Ideas?

init.rb

require ‘find_by_like’
ActiveRecord::Base.send(:include, CH::FIND::LIKE

find_by_like.rb
module CH
module FIND #:nodoc:
module LIKE #:nodoc:

  def self.included(base)
    base.send :extend, ClassMethods
  end

  module ClassMethods

    def find_by_like(col,name)
      query = ":all, :conditions => ['#{col} like %?%', #{name}]"
      self.find(query)
    end
  end

end

end
end

Chris H. wrote:

I am trying to do an active record find method. When I call it from
the console it says method_missing.

No, it probably doesn’t. Please post the exact error message.

Ideas?

init.rb

require ‘find_by_like’
ActiveRecord::Base.send(:include, CH::FIND::LIKE

find_by_like.rb
module CH
module FIND #:nodoc:
module LIKE #:nodoc:

Don’t use all caps for your module names.

  def self.included(base)
    base.send :extend, ClassMethods
  end

  module ClassMethods

    def find_by_like(col,name)
      query = ":all, :conditions => ['#{col} like %?%', #{name}]"

That should be a hash, not a string.

      self.find(query)
    end
  end

end

end
end

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

undefined method `find_by_like’

Why is it not recognizing the method?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs