简体   繁体   中英

ActiveRecord SQL variable substitution

I am trying to write 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM