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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:14:30+00:00 2026-06-07T04:14:30+00:00

My model includes an ‘admin’ field, which is true or false. It is not

  • 0

My model includes an ‘admin’ field, which is true or false. It is not on ‘attr_accessible’ because we don’t want a bad guy to be able to trick our controller into giving ‘admin’ privs to a user.

Because, if I am logged in as an admin in my model, I ‘do’ want to be able to update any user’s record to make or take away admin from them. So… the lack of attr_accessible on admin prevents me from doing so.

Maybe that’s not the right way to look at it. What’s the right way to handle such a case?

  • 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-07T04:14:31+00:00Added an answer on June 7, 2026 at 4:14 am

    Rails 3.2 added a feature that would allow you to do what you’re describing. Simply define this in your model:

    attr_accessible accessible_attributes + [:admin], :as => :admin
    

    And then in the controller where you want to assign the admin attribute, do this:

    User.new(params[:user], :as => :admin)
    

    or

    user.update_attributes(params[:user], :as => :admin)
    

    All the attributes that are listed prior to the attr_accessible call with :as => :admin will be accessible attributes for any Active Record call that supports the :as => :admin option.

    If you didn’t call accessible_attributes in that definition, then only the attributes defined there will be accessible.

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

Sidebar

Related Questions

I have an Event model that includes a start time field, which is stored
I have a Django application which includes a custom model field (and accompanying form
I have a Post model which includes a date_published. I want to display links
I have an ActiveRecord Appointment model, which includes topic and time attributes. I would
I have a model which includes NODES, and RELATIONSHIPS (that tie the nodes together,
I have a very simple model that includes the auto-filled field much like 'created'.
Using Symfony 1.4.5 with Doctrine I have a model which includes an uploaded image
In my app, I have a User model, which includes a number of attributes
I need to define a Meeting model which includes an organiser and a number
I am trying to confirm whether this statement is true: Model includes both: persistence

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.