开发者

ActiveRecord SQL variable substitution

开发者 https://www.devze.com 2023-01-21 10:59 出处:网络
I am trying to wr开发者_Go百科ite this: post_view.id = 1 Comment.find(:all, :conditions => \"post_parent_id = \'post_view.id\'\").size

I am trying to wr开发者_Go百科ite this:

post_view.id = 1

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

The second statement does not work because that is not an appropriate way to write post_view.id .

Anyoone know the proper syntax?


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号