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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:14:40+00:00 2026-06-17T13:14:40+00:00

I am looking for a way to easily apply attr_accessible to all fields in

  • 0

I am looking for a way to easily apply attr_accessible to all fields in a model for a given role, so that I can mass assign all fields in my admin console. I’d like to do something like this:

    class User < ActiveRecord::Base
         attr_accessible :name
         attr_accessible :all, :as => :admin
    end

Using :all obviously doesn’t work. Is there an easy way I can apply attr_accessible to all fields without having to list them all out, as I have a lot of them, and I don’t want to have to remember to do this every time I add a field.

  • 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-06-17T13:14:41+00:00Added an answer on June 17, 2026 at 1:14 pm

    I would implore you to actually take the time to add each field as this offers an opportunity for you to think about whether it actually needs to be attr_accessible. That said, this can be accomplished:

    columns.each do |column|
      attr_accessible column.name.to_sym, :as => :admin
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all, looking to see if theres a way to easily include external html
I was looking for a catch-all way to easily determine whether any user data
I'm looking for a way to easily package and distribute a module that would
I'm looking for a way to convert hex (hexadecimal) to dec (decimal) easily. I
My problem is that I was looking for way to use both storyboard and
I'm looking at way to easily have objects similar to 'fixtures', but for the
I've been looking for a way to easily compress my .js locally before deployment.
I was wondering if anybody knows of a way to easily find all projects
I've been looking all day for a way to procedurally generate 2d texture with
I am looking for a way to easily split a python list in half.

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.