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 6737233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:13:30+00:00 2026-05-26T11:13:30+00:00

Under rails 3.1 If I create a fresh new rails project, and scaffold a

  • 0

Under rails 3.1 If I create a fresh new rails project, and scaffold a new resource like this:

rails g scaffold User name:string email:string

The create action will be like this by default:

def create
  @user = User.new(params[:user])
  respond_to do |format|
    if @user.save
      ...
    else
      ...
    end
  end
end

what I am wondering is, since there is no attr_accessible defined in User model, why this create would work if I post the form to this action. Since attr_accessible will allow mass-assign, but what’s the default here?

  • 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-26T11:13:30+00:00Added an answer on May 26, 2026 at 11:13 am

    The default in Rails is that mass assignment of any database attributes is allowed, you will not need to define that name and email string within the context of attr_accessible for them to able to be mass-assigned.

    Now, attr_accessible is useful if you wish to define a whitelist of attributes that could be massed assigned, if attr_accessible is defined, then only the attributes within attr_accessible will be mass-assigned.

    Similarly, attr_protected is used to define blacklist of attributes that cannot be used in mass assignment.

    None of these things take place unless you define these properties however, that’s why your code works fine without attr_accessible. I personally perfer whitelist approach over the blacklist approach simply because it’s much more secure. Although your application works without attr_accessible, in the end, it is advised you use them anyways as a security precaution.

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

Sidebar

Related Questions

Ok, so I would like to create an action in Rails to restart itself.
Whenever I create a new Ruby on Rails project, I tell SVN to ignore
Rails 3.0.0, Passenger 2.2.15: Create a new Rails project Add gem 'paperclip', :git =>
I would like to create something like this using ruby on rails. Im not
In secret_token.rb under rails initializers, there is secret token appearing as a string of
In Rails 3 edge, I have set up two nested resources like this: config/routes.rb
I am new to rails and read this guide to get all the info
I installed devise successfully: @ubuntu:~/boltzman$ rails generate devise User invoke active_record create db/migrate/20111109080820_devise_create_users.rb create
I'm working on a project in Rails 3 where I need to create an
according to this (older) post these Rails 3 finders have race conditions. Something like

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.