Skip to content

Instantly share code, notes, and snippets.

@alexhanh
Created June 25, 2011 02:54
Show Gist options
  • Select an option

  • Save alexhanh/1046068 to your computer and use it in GitHub Desktop.

Select an option

Save alexhanh/1046068 to your computer and use it in GitHub Desktop.
def set_event
pack = Pack.includes(:replays).find(params[:id])
if !params[:event_id].nil? && !params[:event_id].empty?
event = Event.find(params[:event_id])
pack.replays.update_all(:event_id => event.id)
else
pack.replays.update_all(:event_id => nil)
end
redirect_to pack, :notice => "Event has been updated succesfully for all pack's replays."
end
# AREL (0.4ms) UPDATE "replays" INNER JOIN "pack_games" ON "replays".id = "pack_games".replay_id SET "event_id" = 1 WHERE (("pack_games".pack_id = 25))
# PGError: ERROR: syntax error at or near "INNER"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment