Skip to main content


Showing posts from 2014

Rails Selecting Dropdown display the records selected dropdown value with partial file data?

Rails Selecting Dropdown display the records selected dropdown value with partial file data?

#In Controllers
def select_user_location
 @user_location ="distinct location")

#In Routes
get "user/select_user_location" => "user#select_user_location"

In Views
Select Loaction:
<span class="select_class">
<%= select_tag 'location', options_for_select([["Select Location",'']]+@user_location), :data => { :remote => true, :url => url_for(:controller => "user", :action => "select_user_location")}%></span>
<div id="user_select_location">


 <div class="location_data">
<%@user_location.each do |x|%>


$("#user_select_location").html("<%= escape_javascript(ren…

Kola Gem In rails Getting facebook User Details

graph_api ="xxxxxxxx")
 user_details = graph_api.get_object("me")
 facebook_id = user_detail["id"]
 facebook_email  =  user_detail["email"]
 first_name = user_detail["first_name"]
 last_name = user_detail["last_name"]
 full_name = user_detail["name"]
 gender = user_details["gender"]
location = user_details["location"]["name"]


The O/p of the above data will be like these

"id"=>"10000216852162", "education"=>[{"school"=>{"id"=>"269058053195606", "name"=>"CBHS"},

"type"=>"High School", "year"=>{"id"=>"113125125403208", "name…

Angular Js Examples codes

<!DOCTYPE html>
<script src=""></script>
<!--Example 1 -->
 <div ng-app="" ng-controller="personController">
 First Name: <input type="text" ng-model="firstName"><br>
 Last Name: <input type="text" ng-model="lastName"><br>
Full Name: {{firstName + " " + lastName}}
personController($scope) {
    $scope.firstName = "";
    $scope.lastName = "";

<!--Example 2 -->

<div ng-app="">
first expression {{5*6}}

<!--Example 3 -->
<div data-ng-app="" data-ng-init="firstName='John'">
<p>The name is <span data-ng-bind="firstName"></span></p>

<!--Example 4 -->
<div ng-app=&q…

Rails 3, Devise, Omniauth, and Google

Getting authentication through Google in a Rails application is a breeze with the right tools. To get a simple, no-frills authentication system up and running in a Rails 3 application, all you really need is Devise, Omniauth, and a Google API account.

Step 1: Signing up for Google API access

Before being able to wire up authentication in your rails app, you will need to set up a Google App. First, get your API key at:
If you don’t already have a Google account, you will need to set one up, after that create a project and give it any name you like.

Once you create a project, click on “API Access” and provide details for your OAuth Client. For development purposes, the Home Page URL can be “localhost”.

After all of the details have been set, you will then get access to the screen with all of the information you will for your Rails app. For now, locate the section that contains your Client ID and Client Secret, you will need these later to configure…

Omniauth Linked in Ruby On Rails

def get_linkedin_user_data
     omniauth = request.env["omniauth.auth"]
     linked_app_key = "xxxxxxx"
     linkedin_secret_key = "yyyyyyy"
     client =,linkedin_secret_key)
     connections=client.connections(:fields => ["id", "first-name", "last-name","picture-url"])
  #linked user data
    omniauth = request.env["omniauth.auth"]
     data             =
     user_name        = data["name"]
     user_email       = data["email"]
     user_nickname    = data["nickname"]
     user_firstname   = data["first_name…

Kola Gem Implementaion In Ruby On Rails

Facebook omniauth with kola gem Implementation on Rails 3
1)Gem file add these lines
gem 'koala'

2)Facebook User Details getting

 token = request.env['omniauth.auth']["credentials"]["token"]
   # omniauth = request.env["omniauth.auth"]
   # token = omniauth['credentials']['token']
 @graph =
 #Get The User Details of user
 fb_profile = @graph.get_object("me")
 #Get The Fb user freinds list
 friends = @graph.get_connections("me", "friends")
 firend_ids ={ |friend| friend["id"]}
  image_url = @graph.get_picture(@fb_id)
  image = open(image_url)
      full_name = fb_profile["name"]
      sub_name = fb_profile["first_name"]
      if fb.include?("location")
        location = fb_profile["location"]["name"]
      elsif fb.include?("hometown")
        location = fb_profile["hometown"]["name&quo…

Ezpservices Integration In Ruby on Rails(Cafe Press)

Ezprints  Integration In rails

1)Posting Order to Ezprints and get the shipping values
require 'net/https'
require 'rexml/document'
def shipping_options_ezp_services
      @order = Order.where(:id => 5).first
      @total_orders = Order.all
      xml = "<?xml version='1.0' encoding='UTF-8'?>
      <orders partnerid='45678' version='1'>
     @total_orders.each do |t|
        xml << &q…

Steps for exception notifier Ruby -1.9.2 and Rails 2.3.8 For Exception Notifier in rails

Steps for exception notifier

1)ruby script/generate mailer notifier
2) ruby script/plugin install git:// -r "2-3-stable"
3)lib/notifier.rb to change the ->  @@sender_address = %("Exception Notifier" <>) -> For yahoo only we need to change these line
4)Add these line to  config/environments/development.rb and config/environments/production.rb

config.action_mailer.default_url_options = { :host => 'local host:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
#for gmail
 ActionMailer::Base.smtp_settings = {
   :address              => "",
   :port                 => "587",
   :domain               => '',
   :authentication       => :login,
   :user_name            => '',
   :password             => 'xxxxx',
   :enable_starttls_auto => true

#for yahoo mail

Implementing Roo gem in Rails 3

Roo gem allows us to access the contents of Open-office spreadsheets (.ods)
Excel spreadsheets (.xls)Google (online) spreadsheetsExcel’s new file format .xlsx Following is a basic example to demonstrate how to read the datas from an excel sheet and save to your database.Suppose you have an excel sheet named student_details.xls which contain the student details such as “Name”,”Phone”,”Address”.We have to save them in our database but it will take a huge time if we insert them manually.Here we can user “roo” gem to fetch the datas from excel sheet and save to database in a fly.
Step – 1
Add the gem in your gem file
gem ‘roo’
Then run the ‘bundle install
Step – 2
Place your excel sheet in the rails application such as in public folder.
Step – 3
Now its time to change your controller like below.
Add the following line in your controllerrequire ‘roo’
Create a new method where you will fetch the data from excel sheet and save it in your database.def fetch_excel_data ex =“#{Rails.r…

Ruby roo gem uploading excels

Right so I've checked out Roo. Great gem and all and have a really basic application that doesn't have no models. And basic controller, class and view and I can't seem to get a spreadsheet to upload as I am getting OLE2 signature is invalid error. I have the following basic setup
class SpreadsheetServiceController < ApplicationController def new end def create parser =[:spreadsheet][:file]) respond_to do |format| format.all {render :json => 'Done'} end end end SpreadsheetTagService
class SpreadsheetTagService include Roo def initialize(uploaded_file) @tmp_destination = "#{Rails.root}/tmp/tag-import.xls" @file_path = save_file_to_tmp(uploaded_file) @file = read_file(@file) end private def save_file_to_tmp(uploaded_file), @tmp_destination ) @tmp_destination end …

Ruby On Rails Best gems for Implementation

Ruby On Rails Best gems for Implementation?


    Upload files in your Ruby applications, map them to a range of ORMs, store them on different backends. It works well with Rack based web applications, such as Ruby on Rails.


    Kaminari is a Scope & Engine based, clean, powerful, customizable and sophisticated paginator. Kaminari supports multiple ORMs (ActiveRecord, Mongoid, MongoMapper) multiple web frameworks (Rails, Sinatra), and multiple template engines (ERB, Haml).


    Haml (HTML Abstraction Markup Language) is a layer on top of XHTML or XML that's designed to express the structure of XHTML or XML documents in a non-repetitive, elegant, easy way, using indentation rather than closing tags and allowing Ruby to be embedded with ease. It was originally envisioned as a plugin for Ruby on Rails, but it can function as a stand-alone templating engine.


    A simple, unobtrusive model based Ruby authentication solution. Authlogic is very flexib…

Rails Date Formats

Rails Date Formats
%a - Theabbreviatedweekdayname (''Sun'') %A - Thefullweekdayname (''Sunday'') %b - Theabbreviatedmonthname (''Jan'') %B - Thefullmonthname (''January'') %c - Thepreferredlocaldateandtimerepresentation %d - Dayofthemonth (01..31) %H - Houroftheday, 24-hourclock (00..23) %I - Houroftheday, 12-hourclock (01..12) %j - Dayoftheyear (001..366) %m - Monthoftheyear (01..12) %M - Minuteofthehour (00..59) %p - Meridianindicator (''AM''or''PM'') %S - Secondoftheminute (00..60) %U - Weeknumberofthecurrentyear, startingwiththefirstSundayasthefirstdayofthefirstweek (00..53) %W - Weeknumberofthecurrentyear, startingwiththefirstMondayasthefirstdayofthefirstweek (00..53) %w - Dayoftheweek (Sundayis0, 0..6) %x - Preferredrepresentationforthedatealone, notime %X - Preferredrepresentationforthetimealone, nodate %y - Yearwithoutacentury…