What have you found for these years?

2008-07-22

has_many and find

又是一個討厭的地方...
rails has_many 把 find 吃掉了,
害我 user.habit_contents.find{ |habit|

會吐
ActiveRecord::RecordNotFound:
Couldn't find HabitContent without an ID

結果遠端呼叫就一直 404...

workaround 就加個 to_a 試試

user.habit_contents.to_a.find{ |habit|

這就是為什麼我之前用 select 的原因嗎?

2 retries:

Hinoris said...

煩啊!

決定從今天起,以後每天遊覽Yahoo拍賣的女裝十~二十分鐘,多了解一些女裝的用詞。不然寫來寫去都只是那幾個洋裝、背心之類的,寫著都煩了。

Lin Jen-Shin (godfat) said...

你應該找比較優雅的地方吧 XD
不會想寫跳樓大拍賣吧? XD

Post a Comment

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



All texts are licensed under CC Attribution 3.0