What have you found for these years?

2010-01-10

dm-core 0.10.x 不支援!! (2)

時間到了,雖然看起來 trunk 是解決了,但還是想用標準 gem.
dm-ar-finders copy 了 find_by_sql,
稍微調整一下 const resolution, 直接 copy 會有錯,
因為我是直接放在 User 底下,不是 Resource/Model 上。
整段改寫成:

def friends
# friends_true + friends_false
sqla = "SELECT `users`.* FROM `users` INNER JOIN `cache_friendships` ON" +
"`users`.id = `cache_friendships`.user_false_id WHERE" +
"((`cache_friendships`.user_true_id = #{id}))"

sqlb = "SELECT `users`.* FROM `users` INNER JOIN `cache_friendships` ON" +
"`users`.id = `cache_friendships`.user_true_id WHERE" +
"((`cache_friendships`.user_false_id = #{id}))"

self.class.find_by_sql(sqla) + self.class.find_by_sql(sqlb)
end

看起來是行了。雖然我不知道 friendship 這樣做,
是不是怪怪的,居然拆成兩段。對這方面實在沒什麼經驗...

0 retries:

Post a Comment

Note: Only a member of this blog may post a comment.



All texts are licensed under CC Attribution 3.0