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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:40:03+00:00 2026-06-06T22:40:03+00:00

I am creating a forum software. I want admins and mods to be able

  • 0

I am creating a forum software. I want admins and mods to be able to close certain topics.

Codes are sanitized to show only relevant info.

Models

class User < ActiveRecord::Base
  attr_accessible :name, :email, :password, :password_confirmation, :bio
  has_many :topics, dependent: :destroy
end

class Topic < ActiveRecord::Base
  belongs_to :user
  attr_accessible :name, :last_post_id, :content
end

Schema for user: admin and mod columns determine admins and mods.

create_table "users", :force => true do |t|
  t.string   "name"
  t.string   "email"
  t.datetime "created_at",                         :null => false
  t.datetime "updated_at",                         :null => false
  t.string   "password_digest"
  t.string   "remember_token"
  t.boolean  "admin",           :default => false
  t.text     "bio"
  t.boolean  "mod",             :default => false
end

Schema for topic: closed column determines topic’s closed status.

create_table "topics", :force => true do |t|
  t.datetime "created_at",                      :null => false
  t.datetime "updated_at",                      :null => false
  t.integer  "forum_id"
  t.string   "name"
  t.integer  "last_post_id"
  t.integer  "views"
  t.integer  "user_id"
  t.boolean  "closed",       :default => false
  t.text     "content"
end

I am reluctant to user attr_accessible :closed for TOPIC model because it will be vulnerable to malicious PUT request (correct me if I am wrong).

Is there some way for Rails app to be able to access and modify value of closed column of TOPIC without using attr_accessible, so that only mods and admins can edit them?

  • 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-06T22:40:08+00:00Added an answer on June 6, 2026 at 10:40 pm

    I searched on google and found this ascii cast.

    Basically, you are looking for dynamic attr_accessible.

    If you currently have

    class Article < ActiveRecord::Base  
      attr_accessible :name, :content, :closed  
    end  
    

    You ca use dynamic attr_accessible like this :

    class Article < ActiveRecord::Base  
      attr_accessible :name, :content  
      private  
      def mass_assignment_authorizer  
        super + [:closed]  
      end  
    end  
    

    I hope I is what you are looking for.
    Be sure to check the link I gave you for complete reference.

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

Sidebar

Related Questions

I am creating a forum software using php and mysql backend, and want to
I am creating a forum software. I want to implement closing topic functionality. Closing
I'm creating custom forum software for a site I'm building, which includes 2 tables
I want to automate the process of creating a forum category with the phpBB
I want to use a good mvc naming convention for a forum im creating.
hi friends I am creating a software in java swing where i want to
I am creating a form using only HTML and JavaScript where I want to
I am creating a forum for my school. A student will be able to
Basically i am creating a vbnet system software. I want to create a shortcut
Im creating forum like application and I have textbox where users can enter tags

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.