I'd like to include this Coffee script code in the header of my application.html.haml but I don't know where to put it or how to include ruby objects.
Question 1. How do I render and Javascript .js or Coffeescript .coffee that lives in another file? (where do I put the file, in the assets? in the shared folder?)
Question 2. How do you mixing variables that are in ruby (globals ENV['APP_ID'] for example) see code below:
window.fbAsyncInit = ->
FB.init
appId: "#{ENV['APP_ID']}"
status: true
cookie: true
oauth: true
xfbml: true
((d) ->
js = undefined
id = "facebook-jssdk"
return if d.getElementById(id)
js = d.createElement("script")
js.id = id
js.async = true
js.src = "//connect.facebook.net/en_US/all.js"
d.getElementsByTagName("head")[0].appendChild js
) document
$ ->
$("a").click (e) ->
e.preventDefault()
FB.login ((response) ->
$.get "/auth/facebook/callback" if response.authResponse
),
scope: "#{SCOPE}"