To build on previous answers, SQL injection can be very dangerous for a number of reasons. Injection attacks enable sneaky users to read or manipulate data in your database via the "OR 1.." statement.
Lets say you have an application in which there are many reports you can search. While certain reports should remain hidden to the public, you allow all users to access it like so in your show action:
reports_controller.rb
Reports.where("id = '#{params[:id]}'")
In this format the ' never gets escaped. This allows a user to set attributes directly in your database with an OR 1 statement, a malicious user can generate a query something like:
SELECT * FROM reports WHERE name = '' OR 1--'
Which would in fact return all records in the system to the user. Including ones that shouldn't be visible to them!
Another example would be bypassing the authentication system. If you validate login credentials something like so:
User.find_by("login = '#{params[:name]}' AND password = '#{params[:password]}'")
If the user inputs ' OR '1'='1 as the login value, and ' OR '2'>'1 as the password, the query will look something like:
SELECT * FROM users WHERE login = '' OR '1'='1' AND password = '' OR '2'>'1' LIMIT 1
Then not only would return the first user in the db, but it would also grant full access to the malicious user.
But if you use this format:
User.find_by("login = ? AND password = ?", login_info, password_info).first
And what that will do is escape the ' in the SQL statement so a user cannot exploit the query. You can use the short-hand hash form:
User.find_by(login: login_info, password: password_info)
and your query will still be protected.
Reference: http://guides.rubyonrails.org/security.html#sql-injection a very helpful section with more examples/details on this topic.