Skip to main content

Posts

Showing posts from December, 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
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("<%= escape_javascript(ren…

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", "name…