app/controllers/application_controller.rb
# Check if user likes the page
# If the user is coming from the page itself, then use set flag
# coming_from_page is true, otherwise use social graph
Check if user likes the page
If the user is coming from the page itself, then use set flag
coming_from_page is true, otherwise use social graph
Check if user likes the page If the user is coming from the page itself then use set flag coming_from_page is true otherwise use social graph
def liked_page?(coming_from_page=false)
    if coming_from_page
      signed_data = parse_data
      signed_data["page"].nil? ? false : signed_data["page"]["liked"]
    else
      begin
        client = Koala::Facebook::RestAPI.new(current_user.credentials)
        page_id = @contest.page_id
        results = client.fql_query("SELECT uid FROM page_fan WHERE uid=#{current_user.uid} AND page_id=#{page_id}")
        results.size > 0
      rescue Exception => e
        logger.warn e
        true
      end
    end
  end
def liked_page? ( coming_from_page = false ) if coming_from_page signed_data = parse_data signed_data [ "page" ] . nil? ? false : signed_data [ "page" ] [ "liked" ] else begin client = Koala :: Facebook :: RestAPI . new ( current_user . credentials ) page_id = @contest . page_id results = client . fql_query ( "SELECT uid FROM page_fan WHERE uid=#{current_user.uid} AND page_id=#{page_id}" ) results . size > 0 rescue Exception => e logger . warn e true end end end
Check if user likes the page
If the user is coming from the page itself, then use set flag
coming_from_page is true, otherwise use social graph
Check if user likes the page If the user is coming from the page itself then use set flag coming_from_page is true otherwise use social graph
# This might happen with old sessions that didn't get the offline access # Best way is to consider him liked the app
coming_from_page