2010-10-23 60 views
0

我試圖寫:ActiveRecord的SQL變量替換

post_view.id = 1 

Comment.find(:all, :conditions => "post_parent_id = 'post_view.id'").size 

第二條語句不工作,因爲這是不寫post_view.id的適當方式。

Anyoone知道正確的語法?

+3

「post_view」是否是您未顯示的預先存在的變量?我不明白第一行,或者你想要做的。 'Comment.find(:all,:conditions => [「post_parent_id =?」,post_view.id])。size''也許? – 2010-10-23 17:48:13

+0

是的!這就是謝謝你。 – Trip 2010-10-23 17:51:12

回答

1
post_view.id = 1 
Comment.find(:all, :conditions => ["post_parent_id = ?", post_view.id]).size