【发布时间】:2015-05-18 20:39:27
【问题描述】:
Foundation 似乎不能很好地与 Rails 引擎“配合使用”。我正在设计一个样式布局引擎,以便我可以将该引擎插入并播放到各种后端应用程序中。我很想用 Foundation 来做设计工作,但无论我尝试什么不同的安装技术,我似乎仍然得到相同的错误:
我最初尝试运行:
$rails g foundation:install
返回:
"could not find generator foundation:install"
我仔细检查了我的包,因为我将 zurb-foundation 添加到了我的 gemspec 文件中。它在我的捆绑包中,所以我认为这是我使用 rails 引擎而不是常规 rails 应用程序的兼容性问题。我找到了这篇文章:https://github.com/zurb/foundation/issues/1225
我尝试按照@ivansnek 的指示进行操作。这在我的 chrome 控制台中给了我这些错误:
foundation.js?body=1:26 Uncaught TypeError
foundation.alerts.js?body=1:58 Uncaught ReferenceError: Foundation is not defined
foundation.clearing.js?body=1:517 Uncaught ReferenceError: Foundation is not defined
foundation.cookie.js?body=1:75 Uncaught ReferenceError: Foundation is not defined
foundation.dropdown.js?body=1:184 Uncaught ReferenceError: Foundation is not defined
foundation.forms.js?body=1:556 Uncaught ReferenceError: Foundation is not defined
foundation.joyride.js?body=1:853 Uncaught ReferenceError: Foundation is not defined
foundation.magellan.js?body=1:137 Uncaught ReferenceError: Foundation is not defined
foundation.orbit.js?body=1:432 Uncaught ReferenceError: Foundation is not defined
foundation.reveal.js?body=1:354 Uncaught ReferenceError: Foundation is not defined
foundation.section.js?body=1:431 Uncaught ReferenceError: Foundation is not defined
foundation.tooltips.js?body=1:210 Uncaught ReferenceError: Foundation is not defined
foundation.topbar.js?body=1:371 Uncaught ReferenceError: Foundation is not defined
foundation.interchange.js?body=1:281 Uncaught ReferenceError: Foundation is not defined
foundation.abide.js?body=1:195 Uncaught ReferenceError: Foundation is not defined
application.js?body=1:15 Uncaught ReferenceError: $ is not defined
然后我在这里尝试了基础文档中的常规 ol' 手动安装指南:http://foundation.zurb.com/docs/applications.html 这给了我上面列出的相同错误。有没有人遇到过这些问题,可以指出正确的文档方向,或者向我解释您如何成功地将基础安装到 Rails 引擎中?作为结束说明,基础似乎在我的虚拟应用程序中运行良好。它只是在我的实际引擎中,我无法让它很好地发挥作用。在我的虚拟应用程序中,我能够成功运行基础安装生成器。我的实际引擎需要手动安装,而不是 Rails 生成器。
编辑:
我添加了 gem 'foundation-rails'。所以现在我的引擎中包含了 zurb-foundation gem 和 foundation-rails gem。这消除了我遇到的“未捕获的 ReferenceError”错误。但是现在对 jQuery 的引用不起作用。我的谷歌控制台错误显示“未定义 jQuery”。这让我相信手动安装仍然不顺利。我在我的 application.js 中引用了基础,例如:
//= require foundation
$(document).foundation();
【问题讨论】:
-
"$ 未定义" -> 你的 application.js 中是否有 jQuery?
-
我对出了什么问题以及您想要实现的目标感到有些困惑。您的最终用户是否会添加您的 gem,然后运行
foundation:install生成器?或者您的应用是否有一个生成器,该生成器又调用基础生成器? -
我引擎的安装生成器将调用基础生成器。我想要实现的是创建一个带有前端的模板引擎,我可以将它插入到各种应用程序中。
标签: ruby-on-rails gem zurb-foundation