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

  • Home
  • SEARCH
  • 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 217609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:40:24+00:00 2026-05-11T18:40:24+00:00

I’m currently writing some intranet web application where people could submit to admins requests

  • 0

I’m currently writing some intranet web application where people could submit to admins requests for adding different resources. The example requests would be:

  • installing programs, in this case user will select which program he wants installed
  • increasing quota, in this case user will just enter the amount of disk space he needs or maybe he will select the predefined quantities – 1GB, 10GB etc…
  • create new email alias, in this case user will just type the alias.
  • …

I was thinking about having just one model UserRequests with the reference to the sender and
two optional attributes one would be reference_id that would refefrence to other tables (for
example the Program that he wants installed) and another would be used for free type fields
like email alias or quota.

So my problem is that based on the type of the request the model should contain either:

  • reference to other table
  • integer data
  • string data

Based on the type of the request the given action should be taken – probably email alias
could be added from rails but the application on users computer will be installed by hand.

Does anyone had similar problem? Do you think using polymorphism for this kind of stuff is a good idea? Do you have any suggestions on how to organize data in the tables?

  • 1 1 Answer
  • 2 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-11T18:40:24+00:00Added an answer on May 11, 2026 at 6:40 pm

    Single Table Inheritance! This way you can have each type of request have custom validations, while still having every request live in the same table.

    class CreateUserRequests < ActiveRecord::Migration
      def self.up
        create_table :user_requests do |t|
          t.string :string_data, :type
          t.integer :user_id, :integer_data
          t.timestamps
        end
      end
      def self.down
        drop_table :user_requests
      end
    end
    
    
    class UserRequest < ActiveRecord::Base
      belongs_to :user
    end
    
    class EmailAliasRequest < UserRequest
      validates_presence_of :string_data
      validates_format_of :string_data, :with => EMAIL_REGEX
    end
    
    class ProgramInstallRequest < UserRequest
      belongs_to :program, :class_name => "Program", :foreign_key => "integer_data"
      validates_presence_of :integer_data
    end
    
    class QuotaIncreaseRequest < UserRequest
      validates_presence_of :string_data
      validates_inclusion_of :string_data, :in => %w( 1GB 5GB 10GB 15GB )
    end
    

    And of course, alias your string_data and integer_data to email or whatnot to make your other code have a little more meaning. Let the model be the little black box that hides it all away.

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

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a JSP page retrieving data and when single or double quotes are
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.