Posts

Exporting Data to Excel file in Rails

There are two ways of doing the same thing first is to use the gem to_xls-rails and another is without gem I am gonna explain both approaches: Approach 1 :  Using gem  'to_xls-rails' 1. ) bundle install 2.)Your Controller def index @posts = Post.all respond_to do |format| format.html # don't forget if you pass html format.xls { send_data(@posts.to_xls) } end end 3.)Your View <%= link_to 'Excel Download', posts_path(:format => :xls) %> 4.)config/initializers/mime_type.rb Mime::Type.register "application/vnd.ms-excel", :xls   Another way or standard way without any gem

Integration of Facebook API in Rails Application

To Integrate Facebook API into Rails with yml file  1.)Sign in to your fb account 2.)Type developer.facebook.com in url . 3.)Go to App->Register as a developer. 4.) Now again go to app->add a new app->select which platform are you working on for ex:(website)->enter the name of your app->choose a category->create App id. 5.)After this you will get this 'Setup the Facebook SDK for JavaScript' copy the code to notepad for now. 6.)enter the website url you do have if you don't have any url type example.com 7.)After this you will see four options share login social plugins add 8.)Click any of the option which you want in your app for ex: you clicked on Share. 9.)Then read it for your better understanding to the API. 10.)Now again go to your app from app->your app name 11.)enter the display name anything which you like  12.)enter the mail id of yours for contact 13.)Now copy the app id and secret key and t...

Completely Install and Uninstall mysql on mac

To uninstall MySQL and completely remove it (including all databases) from your Mac do the following: Open a terminal window Use mysqldump to backup your databases to text files! Stop the database server sudo rm /usr/local/mysql sudo rm -rf /usr/local/mysql* sudo rm -rf /Library/StartupItems/MySQLCOM sudo rm -rf /Library/PreferencePanes/My* edit /etc/hostconfig and remove the line MYSQLCOM=-YES- rm -rf ~/Library/PreferencePanes/My* sudo rm -rf /Library/Receipts/mysql* sudo rm -rf /Library/Receipts/MySQL* sudo rm -rf /private/var/db/receipts/*mysql* To install mysql on your mac do the follwo wing things: brew doctor brew install mysql unset TMPDIR mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp mysql.server start / usr / local / Cellar / mysql / 5.5.10 / bin / mysql_secure_installation mysql -h localhost -u root mysql>CREATE DATAB...