0

我正在使用 ruby​​ 1.9.3 Rails 3.2.13 制作可以通过使用对话框(提要对话框)在 facebook 墙上发布的应用程序

在我看来 -

<%
FB.ui(
  {
   method: 'feed',
   name: 'The Facebook SDK for Javascript',
   caption: 'Bringing Facebook to the desktop and mobile web',
   description: (
      'A small JavaScript library that allows you to harness ' +
      'the power of Facebook, bringing the user\'s identity, ' +
      'social graph and distribution power to your site.'
   ),
   link: 'https://developers.facebook.com/docs/reference/javascript/',
   picture: 'http://www.fbrell.com/public/f8.jpg'
  },
  function(response) {
    if (response && response.post_id) 
      alert('Post was published.')
     else 
      alert('Post was not published.')
    end
  }
);
%>

在我的控制器中

def func
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/en_US/all.js'></script>"
  redirect_to root_path
end

在我的视图页面上给出了这个错误 -

uninitialized constant ActionView::CompiledTemplates::FB

在 FB.ui 线上..请帮助我是新手!

4

1 回答 1

0

看起来您正在尝试在视图中混合使用 Ruby 和 JavaScript,但您只需要 JavaScript。尝试从您的视图中删除 erb 标签<%并将 JS 包装在<script>标签中。

于 2013-08-10T21:52:21.213 回答