0
User Load (0.2ms)  SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1  [["id", 2]]
Follow Load (0.2ms)  SELECT "follows".* FROM "follows" WHERE "follows"."follower_id" = 2 AND "follows"."follower_type" = 'User' AND "follows"."blocked" = 'f'
User Load (0.2ms)  SELECT "users".* FROM "users" WHERE "users"."id" IN (1)
Conference Load (0.1ms)  SELECT "conferences".* FROM "conferences" WHERE "conferences"."id" IN (4)
=> [#<Follow id: 8, followable_id: 1, followable_type: "User", follower_id: 2, follower_type: "User", blocked: false, created_at: "2013-08-28 06:57:17", updated_at: "2013-08-28 06:57:17">, #<Follow id: 9, followable_id: 4, followable_type: "Conference", follower_id: 2, follower_type: "User", blocked: false, created_at: "2013-08-28 07:03:35", updated_at: "2013-08-28 07:03:35">]

这是我尝试时在控制台中得到的输出

User.find(2).all_follows

我想获得 followable_type: "Conferece" 所在的行。

我试过这个

 User.find(2).all_follows.find(:conditions => ["followable_type = ?", "Conference"])

 User.find(2).all_follows.where(:all, :conditions => ["followable_type = ?", "Conference"])

当我使用 where 时,它​​说没有这样的功能。但是当我在输入后点击标签时,我得到以下输出

User.find(2).all_follows.where
2).all_follows.where              2).all_follows.where_sql                
2).all_follows.where_values=      2).all_follows.wheres
2).all_follows.where_clauses      2).all_follows.where_values              
2).all_follows.where_values_hash  2).all_follows.wheres=
4

1 回答 1

0

尝试这个..

 User.find(2).all_follows.select{ |user| user.followable_type == "Conference" }
于 2013-08-28T08:31:45.090 回答