This code safe from SQL injection attacks. Escaping is done using ActiveRecord, so every time you invoke the find , create , new / save model, or any other database interaction method, you're fine. The only exception is if you use raw SQL for one of the parameters, for example:
Comment.find(:all, :conditions => "user_id = #{params[:user_id]}")
preferred form:
Comment.find(:all, :conditions => {:user_id => params[:user_id]})
which will be automatically protected from SQL injection.
Alex reisner
source share