【发布时间】:2010-06-21 15:29:50
【问题描述】:
我在试图处理这些错误时已经束手无策了。基本上,我创建了以下用户和关系模式,使用 Mongoid 来处理我的数据库。这似乎是页面底部here 示例的近乎复本。我正在尝试拨打以下任何电话:
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?方法总是返回 true。
我不确定是在线发布代码还是从 gist 发布代码更好,所以这里是要点:
user.rb
user_follow_spec.rb
relationship.rb
我将不胜感激。
【问题讨论】:
标签: ruby-on-rails database mongoid