I can’t seem to get my syntax correct..perhaps this is an easy solve.
I am trying to find all comment objects created after last_checked_mail
I tried..
current_user.comments.find(:all, :conditions => ["created_at > ?, current_user.last_checked_mail"])
But that returns :
ActiveRecord::PreparedStatementInvalid: wrong number of bind variables (0 for 1)
You end the string in the wrong place. It should be:
The error message is saying that you don’t have a variable to back up your ‘?’ in the query. For each ‘?’ in your query string, you need to have an object in the array that gets bound to that question mark. Since you have one ‘?’ in your query, rails is expecting to find one “bind variable” to bind that question mark to.
This is because your string swallowed up the variable you intended to use by mistake.