Reputation: 405
When typing into the rails console
@draft_variables = DraftVariable.where(draft_id: params[:id].to_i)
it returns all rows with the matching ID, while typing
@draft_variables = DraftVariable.where(:draft_id == params[:id].to_i)
returns all rows that have any ID.
Why is this? I'm on Rails 4.1, ruby 2.1.0.
Upvotes: 1
Views: 74
Reputation: 29359
Following statement
@draft_variables = DraftVariable.where(:draft_id == params[:id].to_i)
evaluates to
@draft_variables = DraftVariable.where(false)
Which in turn results in query
SELECT `draft_variables`.* FROM `draft_variables`
So it returns all the records
Upvotes: 3