我在试图处理这些错误时束手无策。基本上,我创建了以下用户和关系模式,使用 Mongoid 来处理我的数据库。这似乎是此处页面底部示例的近似副本。我正在尝试调用以下任何内容:
user1.relationships.find(:all, :conditions => {:rel_user => user_in_question, :rel_type => "following" })
user1.relationships.all(:conditions => {:rel_user => user_in_question, :rel_type => "following" })
user1.relationships.where(:rel_type => "following")
user1.relationships.following #with a named scope
这些似乎都只是返回整个关系数组;他们不按标准搜索。find() 方法也会抛出一个错误,指出它只能接受 1 个参数。im_following?方法总是返回真。
我不确定是在线发布代码还是从要点发布代码更好,所以这里是要点:
user.rb
user_follow_spec.rb
关系.rb
我将不胜感激任何帮助。