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"])
当我在哪里使用时,它说没有这样的功能。但是当我在打字后按Tab键我得到以下输出
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=
答案 0 :(得分:0)
试试这个..
User.find(2).all_follows.select{ |user| user.followable_type == "Conference" }