Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find method redefined #82

Open
drobazko opened this issue Jul 24, 2015 · 3 comments
Open

find method redefined #82

drobazko opened this issue Jul 24, 2015 · 3 comments

Comments

@drobazko
Copy link

Hi, guys.
Seems to be the issue.

Rails 4.1.12
ruby 2.1.0

restaurant.rb

class Restaurant < ActiveRecord::Base
...
acts_as_mappable :through => :address
...
end

So when I try rubyRestaurant.find(1) the exception raised.

2.1.0 :001 > Restaurant.find(1)
  Restaurant Load (12.4ms)  SELECT `restaurants`.* FROM `restaurants`  WHERE `restaurants`.`id` IN (1, '--- {}\n')
ActiveRecord::RecordNotFound: Couldn't find all Restaurants with 'id': (1, {}) (found 1 results, but was looking for 2)
    from /home/drobazko/.rvm/gems/ruby-2.1.0/gems/activerecord-4.1.12/lib/active_record/relation/finder_methods.rb:320:in `raise_record_not_found_exception!'
    from /home/drobazko/.rvm/gems/ruby-2.1.0/gems/activerecord-4.1.12/lib/active_record/relation/finder_methods.rb:452:in `find_some'
    from /home/drobazko/.rvm/gems/ruby-2.1.0/gems/activerecord-4.1.12/lib/active_record/relation/finder_methods.rb:416:in `find_with_ids'
    from /home/drobazko/.rvm/gems/ruby-2.1.0/gems/activerecord-4.1.12/lib/active_record/relation/finder_methods.rb:68:in `find'
    from /home/drobazko/.rvm/gems/ruby-2.1.0/gems/activerecord-4.1.12/lib/active_record/querying.rb:3:in `find'
    from /home/drobazko/.rvm/gems/ruby-2.1.0/gems/geokit-rails-1.1.4/lib/geokit-rails/acts_as_mappable.rb:153:in `find'
    from (irb):1
    from /home/drobazko/.rvm/gems/ruby-2.1.0/gems/railties-4.1.12/lib/rails/commands/console.rb:90:in `start'
    from /home/drobazko/.rvm/gems/ruby-2.1.0/gems/railties-4.1.12/lib/rails/commands/console.rb:9:in `start'
    from /home/drobazko/.rvm/gems/ruby-2.1.0/gems/railties-4.1.12/lib/rails/commands/commands_tasks.rb:69:in `console'
    from /home/drobazko/.rvm/gems/ruby-2.1.0/gems/railties-4.1.12/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /home/drobazko/.rvm/gems/ruby-2.1.0/gems/railties-4.1.12/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:10:in `require'
    from bin/rails:10:in `<main>'
@JPMallow
Copy link

JPMallow commented Dec 1, 2015

Any update on this issue?

@drobazko
Copy link
Author

drobazko commented Dec 2, 2015

@JPMallow,
I have monkey patched it.

config/initializers/geo_patch.rb

module Geokit
  module ActsAsMappable
    module SingletonMethods
      def find(*args)
        prepare_for_find_or_count(:find, args)
        args.last.is_a?(Hash) && args.last.empty? ? super(*args[0..-2]) : super(*args)
      end
    end
  end
end

@JPMallow
Copy link

JPMallow commented Dec 2, 2015

Thanks @drobazko But, I have moved to geocoder gem as it does my work as charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants