Reputation: 379
I have a form the has the users import a score. I am wanting that score to be passed into the sql string. This is what I have so far.
numbers = NumbersTest.find_by_sql('select phone_number, person_id from numbers_tests where score = ?', params[:score])
that keeps giving me a undefined method empty?' for nil:NilClass
error.
Any ideas what I am doing wrong?
Upvotes: 0
Views: 39
Reputation: 42789
I'd do a normal Active Record query:
numbers = NumbersTest.select(:phone_number, :person_id).where(score: params[:score])
Upvotes: 1