Skip to content

Instantly share code, notes, and snippets.

@crova
Created January 30, 2017 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save crova/657a436d584aa2568d5f9be2b6a2f412 to your computer and use it in GitHub Desktop.
Save crova/657a436d584aa2568d5f9be2b6a2f412 to your computer and use it in GitHub Desktop.
How to run this task with delayed_job
# fetchs SIB Account information
def sib_account_fetch
sib = Mailin.new("API_URL","API_KEY")
acct = sib.get_account()
acct.dig('data')
credits = acct.dig('data', 0).to_h
SibAccount.find(1).update_attributes(credits)
details = acct.dig('data', 2).to_h
SibAccount.find(1).update_attributes(details).delay
redirect_to(:controller => 'monet', :action => 'refresh')
flash[:notice] = "Account Info updated successfully."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment