Giter VIP home page Giter VIP logo

nazrin's People

Contributors

amhol avatar rutan avatar totem3 avatar tsuwatch avatar yefim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nazrin's Issues

Multiple Models

Is this gem supporting multiple models? I guess the gem supports 1 model at the same time.
Do you have a plan for supporting multiple models?

Better documentation please

I'm having a hard time understanding what to pass into .search and .query. It would be great to document the options hash that .search takes in. If you flesh out some of the documentation, I would be more than willing to contribute some more in the same pattern!

undefined method xxx for nil:NilClass when options given to search

Description

  • When using ActiveRecord data accessor or Mongoid data accessor
  • and pass options to search and call execute causes undefined method error like following.
  • This error can be reproduce by the steps which is explained later.
     NoMethodError:
       undefined method `in' for nil:NilClass
     # ./lib/nazrin/data_accessor/mongoid.rb:10:in `block in load_all'
     # ./lib/nazrin/data_accessor/mongoid.rb:6:in `each'
     # ./lib/nazrin/data_accessor/mongoid.rb:6:in `load_all'
     # ./lib/nazrin/data_accessor.rb:64:in `results'
     # ./lib/nazrin/search_client.rb:122:in `execute'
     # ./spec/nazrin/data_accessor/mongoid_spec.rb:27:in `block (4 levels) in <top (required)>'

The error occurs here .

model = model.send(k, v)

In this code, right side model is not the method of DataAccessor but nil, because by executing model = , model is defined as a new local variable. So we failed to call methods.

Environment

  • ruby 2.5.3
  • nazrin 2.6.1
  • with rails 5.2.0 or mongoid 7.0.2

How to reproduce

Apply this patch and execute rspec.

patch
diff --git a/spec/nazrin/data_accessor/mongoid_spec.rb b/spec/nazrin/data_accessor/mongoid_spec.rb
index 9773fea..fa1b662 100644
--- a/spec/nazrin/data_accessor/mongoid_spec.rb
+++ b/spec/nazrin/data_accessor/mongoid_spec.rb
@@ -1,6 +1,6 @@
 require 'spec_helper'
 
-describe Nazrin::DataAccessor::Mongoid do
+describe 'Nazrin::DataAccessor::Mongoid' do
   let!(:user) { User.create(email: '[email protected]', created_at: Time.now) }
 
   it { expect(User).to be_respond_to :search }
@@ -22,5 +22,9 @@ describe Nazrin::DataAccessor::Mongoid do
       it { expect(User.search.size(1).start(0).execute).to eq [user] }
       it { expect(User.search.size(1).start(0).execute.facets).to eq(response.facets) }
     end
+
+    context 'with options' do
+      it { expect(User.search({in: {email: ['[email protected]']}}).size(1).start(0).execute).to eq [user] }
+    end
   end
 end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.