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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:45:18+00:00 2026-05-26T01:45:18+00:00

I currently have a notifications table in rails which contains the columns: notification_type, notification_id

  • 0

I currently have a notifications table in rails which contains the columns: “notification_type”, “notification_id”

Where the notification type is either “Post”, “Friend”, “Rating”. I have separate tables called the same names as the notification type.

What I want to do is be able to use the notification_type and ID to get the correct data from the other tables. ie A row with a notification_type of “Post” and an ID of 1 should get the the data from the Post table where the id is 1. (However, I want to get more than just one row from Post if there are more rows with “Post” notification_type).

I also need to combine all the data retrieve from the three tables together so I can have something like:

@all_notifications = ...

And call something like this from my view:

@all_notifications.each do |notification|
    if notification.type == "Post"
        <%= notification.post_content %>
    end
end

Alternatively, I’m open for a better suggestion on how to organise my tables.

Thanks in advance

  • 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-05-26T01:45:19+00:00Added an answer on May 26, 2026 at 1:45 am

    So far it sounds like you want polymorphic associations.

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

Sidebar

Related Questions

I have a notifications table which contains different types of notifications for different events.
Currently I have a aspx page that is defined as: <%Using Html.BeginForm(SaveNotifications, Notifications, FormMethod.Post,
I have a model called Notifications, which basically acts as a join table between
I have a table which has fields date_of_notification, date_of_loss. Both are of type time-stamp.
I currently have a functioning in-house Windows Forms application which extensively uses the DataGridView
I currently have a notification in my Android application that has a PendingIntent so
I currently have the following code: <%@ WebService Language=C# Class=Notifications %> using System; using
Given a Database that has a table Called [Bid Transactions], which contains records of
I have a mysql table which will store users email addresses (each is unique
I have a Scroll View, Table View, and textfield at the bottom which will

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.