{"_id":"538cf51a3325b9e6626b5897","__v":2,"tags":[],"user":"5384345d90c19d5e43a8170c","comments":[],"category":{"_id":"541e82877eb16bb64f83c0ca","version":"53844558a43e08da4677be12","__v":1,"pages":["538cf51a3325b9e6626b5897","538cfd183325b9e6626b5898","538cf4ac3325b9e6626b5896","53daa04f971607581f86ea2e","560332f790ee490d004403ac"],"project":"53844557a43e08da4677be0e","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-09-21T07:47:19.722Z","from_sync":false,"order":4,"slug":"libraries","title":"Libraries"},"project":"53844557a43e08da4677be0e","version":{"_id":"53844558a43e08da4677be12","__v":8,"project":"53844557a43e08da4677be0e","createdAt":"2014-05-27T07:57:12.136Z","releaseDate":"2014-05-27T07:57:12.136Z","categories":["53844558a43e08da4677be13","538619e1ef91f96d49aa1a0b","541e82877eb16bb64f83c0ca","5445a073c3eb3808000c76b2","5445a098c3eb3808000c76b3","54bb05ab522f03150054d9e8","54bb05cf9741c81500078f73","55b7d0e5568be2230092bb92"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"false","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-06-02T22:05:14.532Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Rails Gem\"\n}\n[/block]\nFor those writing Rails apps, we have a Gem that you can use to make connecting to Knowtify much easier.\n\nYou can find and download the Gem [here](https://github.com/DaneLyons/knowtify-gem).\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Sample Code\"\n}\n[/block]\nIf you'd rather not use the Gem, this is an example of how you might connect to the Knowtify API if you're running a Rails app. This is a rake task designed to be sent out using your favorite scheduler (Heroku Scheduler).\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"desc \\\"Send digest data to Knowtify.io\\\"\\ntask :daily_knowtify_digest => :environment do\\n  require \\\"net/http\\\"\\n  require \\\"uri\\\"\\n\\n  #logic to collect user data\\n  #contacts = User.where(:subscribed => true).select([:email,:name,:followers,:comments])\\n  #contacts = User.where(:subscribed => true).select([:email,:name,:image,:tasks])\\n\\t\\n  post_params = { \\n    :contacts => contacts\\n  }\\n  \\n  uri = URI.parse(\\\"http://www.knowtify.io/api/v1/contacts/upsert\\\")\\n  req = Net::HTTP::Post.new(uri.path)\\n  req.body = JSON.generate(post_params)\\n  req[\\\"Content-Type\\\"] = \\\"application/json\\\"\\n  req[\\\"Authorization\\\"] = 'Token token=\\\"[KNOWTIFY_API_TOKEN]\\\"'\\n\\t  \\n  http = Net::HTTP.new(uri.host, uri.port)\\n  response = http.start {|htt| htt.request(req)}\\n  puts response.body\\nend\",\n      \"language\": \"ruby\",\n      \"gist\": \"b8d9e6af54113b29d587\"\n    }\n  ]\n}\n[/block]","excerpt":"For those connecting Rails apps with the Knowtify API","slug":"rails--the-knowtify-api","type":"basic","title":"Rails Gem"}

Rails Gem

For those connecting Rails apps with the Knowtify API

[block:api-header] { "type": "basic", "title": "Rails Gem" } [/block] For those writing Rails apps, we have a Gem that you can use to make connecting to Knowtify much easier. You can find and download the Gem [here](https://github.com/DaneLyons/knowtify-gem). [block:api-header] { "type": "basic", "title": "Sample Code" } [/block] If you'd rather not use the Gem, this is an example of how you might connect to the Knowtify API if you're running a Rails app. This is a rake task designed to be sent out using your favorite scheduler (Heroku Scheduler). [block:code] { "codes": [ { "code": "desc \"Send digest data to Knowtify.io\"\ntask :daily_knowtify_digest => :environment do\n require \"net/http\"\n require \"uri\"\n\n #logic to collect user data\n #contacts = User.where(:subscribed => true).select([:email,:name,:followers,:comments])\n #contacts = User.where(:subscribed => true).select([:email,:name,:image,:tasks])\n\t\n post_params = { \n :contacts => contacts\n }\n \n uri = URI.parse(\"http://www.knowtify.io/api/v1/contacts/upsert\")\n req = Net::HTTP::Post.new(uri.path)\n req.body = JSON.generate(post_params)\n req[\"Content-Type\"] = \"application/json\"\n req[\"Authorization\"] = 'Token token=\"[KNOWTIFY_API_TOKEN]\"'\n\t \n http = Net::HTTP.new(uri.host, uri.port)\n response = http.start {|htt| htt.request(req)}\n puts response.body\nend", "language": "ruby", "gist": "b8d9e6af54113b29d587" } ] } [/block]