Skip to content

Instantly share code, notes, and snippets.

View holgersindbaek's full-sized avatar

Holger Sindbaek holgersindbaek

View GitHub Profile
@holgersindbaek
holgersindbaek / uninkd_publish
Last active December 11, 2015 21:39
Something is wrong here. I keep getting the following error: field articles not an array It saves the magazine and the issue and links up the relationship there. It also links up the relationship on the first article and it saves the second article (without linking it up to the relationship). And then it crashes. What am I doing wrong here?
def publish
require 'parse-ruby-client'
Parse.init :application_id => "App_ID", :api_key => "App_Key"
@magazine = Magazine.find(params[:magazine_id])
@issue = Issue.find(params[:id])
# Checking to see whether we have a magazine already. Making a new one if we don't and grabbing the old one if we do.
current_magazine = Parse::Query.new("Magazine").value_in("title", [@magazine.title]).get
magazine = nil
if current_magazine.length == 0