Posts

Showing posts with the label gems

Exporting CSV and Excel File In ROR.

It’s very common now a days to export data from a Web application in CSV or Excel format and in this post i will show how to do that in a Rails application.  Exporting to CSV:- Step:1  /config/application.rb require File . expand_path( '../boot' , __FILE__ ) require 'csv' require 'rails/all' Step:2    /app/controllers/products_controller.rb class ProductsController < ApplicationController def index @products = Product . order( :name ) respond_to do | format | format . html format . csv { render text : @products . to_csv } end end end Step:3  /app/models/product.rb class Product < ActiveRecord : :Base attr_accessible :name , :price , :released_on def self . to_csv CSV . generate do | csv | csv << column_names all . each do | product | csv << product . attributes . values_at( * column_names) end end end end Ste...

Push Notifications for IOS and Android In rails 4

APN's :- Apple Push Notification service ( APNs ) is a remote notifications feature provided by apple inc. It is a robust and highly efficient service for propagating information to iOS (and, indirectly, watchOS ), tvOS , and OS X devices. Each device establishes an accredited and encrypted IP connection with APNs and receives notifications over this persistent connection. If a notification for an app arrives when that app is not running, the device alerts the user that the app has data waiting for it. How it works:- The device token you provide to the server is analogous to a phone number; it contains information that enables APNs to locate the device on which your client app is installed. APNs also uses it to authenticate the routing of a notification. The device token is provided to you by your client app, which receives the token after registering itself with the remote notification service. GCM:- Google Cloud Messaging is used to send push notification on android...