Neo4j.rb过滤参数时如何进行一次查询可能存在也可能不存在?

时间:2016-12-23 20:10:50

标签: ruby-on-rails cypher neo4j.rb

用户和地点是具有has_many realtionship的两个节点

@places = User.find(4).places

@places = @places.where(dog: false) if params[:no_dogs]

我可以将这两者合二为一,这样如果param出现那么它就会涉及其他条件下忽视它的条件

1 个答案:

答案 0 :(得分:0)

我不相信find()方法接受零参数。也许你想要这个?

@places = User.places # Calling the association gives an unexecuted proxy to a query to build

@places = @places.where(dog: false) if params[:no_dogs]

或者,如果您想使用User模型:

@users = User.all

@users = @users.where(dog: false) if params[:no_dogs]