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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:17:16+00:00 2026-06-07T14:17:16+00:00

In my application I have a polymorphic Idea model. I want to use it

  • 0

In my application I have a polymorphic Idea model. I want to use it with different entities like project, opportunity etc.
In the idea table it is differentiated using ideable_id and ideable_type.
So as an example, for a Project ideable_id is the project_id and ideable_type is Project.
For Opportunity ideable_id is the opportunity_id and ideable_type is Opportunity

I want to create an idea for a model called ideabank. ideabank is a virtual model, it’s not an entity like project or opportunity. How should I create such a model without a database representation which will give me ideable_id and ideable_type?
Or should I leave the fields for ideable_id and ideable_type free while adding idea to ideabank?

  • 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-07T14:17:19+00:00Added an answer on June 7, 2026 at 2:17 pm

    If you are using rails 3, see this
    http://railscasts.com/episodes/219-active-model

    models/message.rb

    class Message
      include ActiveModel::Validations
      include ActiveModel::Conversion
      extend ActiveModel::Naming
    
      attr_accessor :name, :email, :content
    
      validates_presence_of :name
      validates_format_of :email, :with => /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i
      validates_length_of :content, :maximum => 500
    
      def initialize(attributes = {})
        attributes.each do |name, value|
          send("#{name}=", value)
        end
      end
    
      def persisted?
        false
      end
    end
    

    messages_controller.rb

    def create
      @message = Message.new(params[:message])
      if @message.valid?
        # TODO send message here
        flash[:notice] = "Message sent! Thank you for contacting us."
        redirect_to root_url
      else
        render :action => 'new'
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have content management system application that uses a polymorphic tree table as the
I have a Phone model for phone numbers in my application thats built as
I want to have one model & view that is served by multiple controllers
I am writing ruby on rails application, which will have 2 different users types
I would like to create an application that would use the same system as
I have a relationship table in a rails application called edit_privileges , in which
I have a web application in rails 3 that already has a polymorphic paperclip
I have project model that has many tasks. Both project and tasks can have
I have an application in C#, i want to implement perfcounters in this application
My application have something like this: TabActivity Tab 1 (ActivityGroup) Activity > Activity >

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.