次のように定義された Facebook アプリ ID の構成変数があるとします。
TestSiteRails::Application.configure do
config.facebook_app_id = '123146123188122'
end
この変数をすべてのアクションで使用できるようにして、メイン レイアウト application.html.haml で使用できるようにします。
!!! html
%html
%head
%body
#fb-root
:javascript
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : '#{@facebook_app_id}', // Configured facebook app id
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File for x-domain communication
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
xfbml : true // parse XFBML tags on this page?
});
= yield :contents
各コントローラー アクションでこれを行うコードを繰り返すのではなく、どのようにすればこれをすべてのアクションで使用できるようにできますか?