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=