我收到了无限量的这条消息(就像循环一样),它破坏了网站
Rails 4.0.0(带有 Turbolinks)
错误信息
阻止来源为“ https://www.facebook.com ”的框架访问来源为“ http://app.herokuapp.com ”的框架。请求访问的帧具有“https”协议,被访问的帧具有“http”协议。协议必须匹配。
Facebook.js.coffee
fb_root = null
fb_events_bound = false
$ ->
loadFacebookSDK()
bindFacebookEvents() unless fb_events_bound
bindFacebookEvents = ->
$(document)
.on('page:fetch', saveFacebookRoot)
.on('page:change', restoreFacebookRoot)
.on('page:load', ->
FB?.XFBML.parse()
)
fb_events_bound = true
saveFacebookRoot = ->
fb_root = $('#fb-root').detach()
restoreFacebookRoot = ->
if $('#fb-root').length > 0
$('#fb-root').replaceWith fb_root
else
$('body').append fb_root
loadFacebookSDK = ->
window.fbAsyncInit = initializeFacebookSDK
$.getScript("//connect.facebook.net/it_IT/all.js")
initializeFacebookSDK = ->
FB.init
channelUrl : 'http://app.heroku.com/page/fbchannel'
appId : 'MY_ID_HERE'
status : true
cookie : true
xfbml : true
页面控制器
class PageController < ApplicationController
skip_before_action :authenticate_user!
def fbchannel
cache_expire = 1.year
response.headers["Pragma"] = "public"
response.headers["Cache-Control"] = "max-age=#{cache_expire.to_i}"
response.headers["Expires"] = (Time.now + cache_expire).strftime("%d %m %Y %H:%I:%S %Z")
render :layout => false, :inline => "<script src='//connect.facebook.net/it_IT/all.js'></script>"
end
end
FBlike(帮手)
def fblike(resource, layout = 'standard')
content_tag(:div, "", class:"fb-like", data: {
href: polymorphic_url(resource),
width: "225",
show_faces: false,
stream: false,
show_border: false,
header: false,
layout: layout
}
)
end