Skip to main content

Posts

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 user_controller.rb def select_user_location  @user_location = User.select("distinct location") end #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> _select_user_location.html.erb  <div class="location_data"> <%@user_location.each do |x|%> <p><%=x.inspect%></p> <%end%>  </div> select_user_location.js.erb $("#user_select_location").html(...

Kola Gem In rails Getting facebook User Details

graph_api = Koala::Facebook::API.new("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...

Angular Js Examples codes

<!DOCTYPE html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script> </head> <body> <!--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>  <br> Full Name: {{firstName + " " + lastName}} </div> <script> function personController ($scope) {     $scope.firstName = "";     $scope.lastName = ""; } </script> <!--Example 2 --> <div ng-app=""> first expression {{5*6}} </div> <!--Example 3 --> <div data-ng-app="" data-ng-init="firstName='John'"> <p>The name is <span data-ng-bind="firstName"></span></p> <!--Example...

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:  https://code.google.com/apis/console 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 ...

Omniauth Linked in Ruby On Rails

def get_linkedin_user_data      omniauth = request.env["omniauth.auth"]      dat=omniauth.extra.raw_info      linked_app_key = "xxxxxxx"      linkedin_secret_key = "yyyyyyy"      client = LinkedIn::Client.new(linked_app_key,linkedin_secret_key)      client.authorize_from_access(omniauth['credentials']['token'],omniauth['credentials']['secret'])      connections=client.connections(:fields => ["id", "first-name", "last-name","picture-url"])      uid=omniauth['uid']      token=omniauth["credentials"]["token"]      secret=omniauth["credentials"]["secret"]   #linked user data     omniauth = request.env["omniauth.auth"]      data             = omniauth.info      user_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 = Koala::Facebook::API.new(token)  #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 = friends.map{ |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?("...

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'>       <ordersession>       <order>       <orderid>#{@order.id}</orderid>       <shippingaddress>       <firstname>#{@order.first_name}</firstname>       <address1>#{@order.address1}</address1>       <city>#{@order.city}</city>       <state>#{@order.stat...