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 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 sound like an obvious question but I can't seem to find the
This might seem like an unordinary json question but I can assure you I
This might seem like a dumb question, but can GameKit be used for apps
This might seem like a strange question, but can I actually shut down the
I know this might seem like a duplicate, but I'm not getting anywhere with
This might seem like a very easy question for some of you folks, but
This might seem like a weird question, but bear with me. I'd like to
This might seem like a trivial question, but I'm a bit muddled in my
This might seem like a really dumb question, but I am writing an application
This might seem like a stupid question but it's been a long day. I'm

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.