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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:08:14+00:00 2026-05-21T10:08:14+00:00

This might seem like a duplicate question, but I can’t find any information on

  • 0

This might seem like a duplicate question, but I can’t find any information on this. I want to show the results from a remotely acquired json array excluding certain results by comparing them to a local table. I have a gallery model with:

t.integer :smugmug_id
t.string :smugmug_key
t.integer :category_id
t.string :category_name
t.string :description
t.integer :highlight_id
t.string :highlight_key
t.string :highlight_type
t.string :keywords
t.string :nicename
t.integer :subcategory_id
t.string :subcategory_name
t.string :title
t.string :url

The data for this model gets populated by a rake task that connects to the smugmug api (json) and stores the data locally. I’m trying to create a view that shows all the smugmug galleries that are not stored locally.

Here’s what I’ve tried so far, but it’s not excluding the locally stored galleries like I thought it would.

def self.not_stored
  smugmug_list = Smug::Client.new.albums(heavy = true)
  gallery_list = Gallery.select(:smugmug_id)
  smugmug_list.each do |smugmug|
    smugmug unless gallery_list.include? smugmug.id
  end
end

Hopefully this makes sense. I’m getting a json array of galleries, and I want to display that array excluding results where the album id matches the smugmug_id of any of my locally stored records.

Quick edit: I’m using an adaptation of this gem to connect to the smugmug api.

  • 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-21T10:08:14+00:00Added an answer on May 21, 2026 at 10:08 am

    Just use the difference operator.

    General Example:

    ruby-1.9.2-p136 :001 > [3,2,1] - [2,1]
     => [3] 
    

    So you would have:

    smugmug_list.collect{|e| e.id} - gallery_list
    

    Enumerable#collect will turn the smugmug_list into a list of id’s. From there, you can do the difference operator, which will return all the id’s of all the smugmug galleries that are not stored locally.

    Another option to maintain the list of galleries:

    smugmug_list.select{|e|!gallery_list.include?(e.id)}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might seem like a stupid question I admit. But I'm in a small
Ok sorry this might seem like a dumb question but I cannot figure this
This might sound like a little bit of a crazy question, but how can
This might seem like a ridiculous question since I'm quite inexperienced in .NET. Is
This question might not seem programming related at first, but let me explain. I'm
This might seem obvious but I've had this error when trying to use LINQ
I can't seem to get a custom action working. I might be doing this
This might be on the discussy side, but I would really like to hear
This might be an interesting question. I need to test that if I can
This might be a bit on the silly side of things but I need

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.