Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 892933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:08:22+00:00 2026-05-15T14:08:22+00:00

Does build protect against sql injection? Example: @post = @user.posts.build(params[:post]) @post.save Didn’t see build

  • 0

Does build protect against sql injection?

Example:

@post = @user.posts.build(params[:post])
@post.save

Didn’t see build in the rails security docs.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T14:08:23+00:00Added an answer on May 15, 2026 at 2:08 pm

    build itself doesn’t write anything to the database so SQL injection doesn’t apply. When you call save it doesn’t matter whether the object was created via build or via another mechanism such as passing attributes to new or using individual attribute= methods, the same code will be used to save your object to the database.

    From the documentation on build:

    Returns a new object of the collection
    type that has been instantiated with
    attributes and linked to this object
    through the join table, but has not
    yet been saved.

    The save method will escape any quotes etc in your attribute values using a method appropriate to the database you’re using (e.g. MySQL) so that the resulting insert or create query is not susceptible to SQL injection. The same applies to update_attributes and to any parameterised :conditions that you pass to find. The time when you need to be careful and may need to do some manual escaping is if you are ever passing literal strings to the database connection as queries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How does one build a function that can set an arbitrary value within a
Currently we have a script that does maven build + tomcat deploy. Deploying to
Does anybody have experience build app with PhoneGap's Build Service? I followed the steps
Does it make a sense to use a build server in a small (2-3
Does .NET 3.5 provide any build-in support for charts and graphs for Windows Forms
Does anyone have any experiences from recent daily build of AnkhSVN? Please let me
Does anyone know if (and how) I can build an application (Java/Ruby/whatever) doing REST
Does shipping .pdb files in a release build of a .NET application incur a
Does anyone know of a clojure library to build sitemap.xml files? If no such
I have a build in TeamCity which runs against a project file names Web.csproj

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.