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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:34:53+00:00 2026-05-29T09:34:53+00:00

this is a real hair-puller. I’ve got a junction table that I need to

  • 0

this is a real hair-puller. I’ve got a junction table that I need to query for 2 different entries, then update the junction table if the values are not there already.

Essentially I have this:

master_actors = [#<Actor2role actorId: 13176, dogTag: 45917, roleId: 1, position: 3>, #<Actor2role actorId: 65471, dogTag: 45917, roleId: 291075, position: 1>]

slave_actors = [#<Actor2role actorId: 11123, dogTag: 5384, roleId: 44, position: 5>, #<Actor2role actorId: 65471, dogTag: 5384, roleId: 291075, position: 0>, #<Actor2role actorId: 66652, dogTag: 5384, roleId: 291073, position: 2>]

I need to compare the contents of each one of those records and if there are entries in slave_actors not present in master_actors I need insert them.

What I can’t figure out is how to compare the contents of those 2 activeRecord relationship objects. Regular array methods like .include? don’t seem to work. Nor does master_actors.attributes == slave_actors.attributes because I get an error saying that the attributes method does not exist for an activeRecord relationship.

Basically I’m really stumped.

Any help would be appreciated.

  • 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-29T09:34:54+00:00Added an answer on May 29, 2026 at 9:34 am

    Have you tried checking if the intersection (ary1 & ary2) is empty ?

    EDIT : As mentioned in the comments below, since there is elements in master_actors that can be absent from slave_actors, the difference (ary1 - ary2) was the right answer

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

Sidebar

Related Questions

In a .f file there is code that does this: real Bob, avar ...
This is a real newbie question. I have simple app that selects a picture
If this is not a real question then feel free to close ;)
This doesn't need to be a real time solution, but are there some log
update - if I remove the runat=server this does not happen...then how do I
I have multiple entries in a temporary table in Database, and I need to
Okay this is a real headscratcher. I have an application which calls a web
Note: this is not real information: $ ssh-keygen -t rsa -C "tekkub@gmail.com" Generating public/private
This one is a real head scratcher for me... var matches = Regex.Matches(<p>test something<script
This is not a real bug BUT for sure it is not what you

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.