Trip
Trip

Reputation: 27114

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?

Upvotes: 0

Views: 860

Answers (1)

nathanvda
nathanvda

Reputation: 50057

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

Upvotes: 1

Related Questions