我希望能够为用户提供完全控制并编辑布局.我还希望他们能够包含他们想要的javascript插件.因此,我必须创建一个允许他们这样做的界面.
例如,默认的html看起来像这个更复杂的版本:
<head>
<title>{{site.name}}</title>
...
{{js_plugins.colorbox}} # this should return the necessary javascript and/or stylesheet tags
</head>
Run Code Online (Sandbox Code Playgroud)
我的Liquid JsPlugins drop是这样的:
class JsPluginsDrop < Liquid::Drop
include ActionView::Helpers::AssetTagHelper
...
def colorbox
javascript_include_tag "/path/to/js"
end
end
Run Code Online (Sandbox Code Playgroud)
当我运行我的规范时,我得到了这个错误(请注意,你看到@drop["colorbox-1.3.15"]我上面提供的代码行为不同.但是,我想简化我的代码,因为这不是问题,这是问题的用法TagHelper):
Failures:
1) JsPluginsDrop colorbox-1.3.15 should return the correct script tags
Failure/Error: @drop["colorbox-1.3.15"].stylesheets.should include("/jquery-plugins/colorbox-1.3.15/example1/colorbox.css")
undefined local variable or method `config' for #<JsPluginsDrop:0xcbfab38>
# ./app/drops/js_plugins_drop.rb:22:in `stylesheets'
# ./spec/models/js_plugins_drop_spec.rb:11
Run Code Online (Sandbox Code Playgroud)
如果问题是由于它与我的Rails环境分开,并且drop无法访问Rails,我不会感到惊讶config.由于我仍然希望能够使用这些方便的方法,并且:cache => true如果可能的话,如何在drop中使用stylesheet_link_tag和javascript_include_tag?
我一直想弄清楚我将如何用Liquid进行递归.我有一个应用程序,我想让用户完全控制菜单的呈现.但是,菜单是由树定义的,因此需要Liquid中的递归函数.
我该怎么做?做了一些阅读后,我以为我会这样解决它:
包括
我想用include这种方式:
<ul id='site_nav' class='nav'>
{{ include 'menu_item' with menu_items }}
</ul>
Run Code Online (Sandbox Code Playgroud)
而menu_item部分是这样的:
<li id='{{menu_item.dom_id}}' class='{{menu_item.css_menu_class}}'>
{{ menu_item.name }}
<ul>
{{ include 'menu_item' with menu_item.children }}
</ul>
</li>
Run Code Online (Sandbox Code Playgroud)
但是,由于它是用户可编辑的,我需要破解Liquid以使其从数据库加载部分内容.由于这需要花费更多的时间来学习,我想先问一下是否有人之前已经解决了这个问题.
提前致谢!
仅当开发人员在特定操作系统上时,才需要在开发中安装一些gems。在我的特定情况下,我想为Linux创建一个小组。
我如何为此分组?
我希望有能力的测试正确的样式表的交换在我的测试套件.有了这篇关于使用Capybara测试页面标题的帖子,我想我可以在页面link的head部分测试任何标签.但似乎我错了.
这样的步骤:
save_and_open_page
page.should have_xpath("//link") # just something as simple as this, first.
Run Code Online (Sandbox Code Playgroud)
save_and_open_page 生成这样的HTML(为简洁起见,删除了一些内容):
<head>
...
<link href="/home/ramon/source/unstilted/public/system_test/stylesheets/fancake/css/2.css?1323572998" type="text/css" class="jquery-styler" rel="stylesheet">
...
</head>
Run Code Online (Sandbox Code Playgroud)
但我得到了这个失败:
expected xpath "//link" to return something (RSpec::Expectations::ExpectationNotMetError)
Run Code Online (Sandbox Code Playgroud)
鉴于这一切,我如何测试样式表?
谢谢!
我一直在尝试应用Square的方法将Resque包含在他们的集成测试中而没有太多运气.自2010年8月以来,我不确定Resque和/或Cucumber是否发生了很大的变化.
下面你会找到我采取的方法,也许你可以:
Square的博客文章没有明确的安装步骤,所以这就是我所做的:
features/support/cucumber_external_resque_worker.rbconfig/initializers/cucumber_external_resque.rb,执行以下操作:
require 'features/support/cucumber_external_resque_worker'CucumberExternalResqueWorker.install_hooks_on_startupcucumber_external_resque_worker.rb,我改变的情况下,Rails.env.cucumber?到Rails.env.test?因为黄瓜是在运行特点test的环境(我做了一些puts Rails.env在cucumber_external_resque_worker.rb是肯定的.uninitialized constant WorkerBase (NameError).也许Resque改变了它命名的方式.提前致谢!
我希望能够这样拯救I18n::MissingTranslationData:
begin
value = I18n.t('some.key.that.does.not.exist')
puts value
return value if value
rescue I18n::MissingTranslationData
puts "Kaboom!"
end
Run Code Online (Sandbox Code Playgroud)
我尝试了上面的内容,但它似乎没有进入救援区.我只是看到,我(因为控制台puts)translation missing: some.key.that.does.not.exist.我从来没有见过Kaboom!.
我如何让它工作?
当我想查找具有分配给它的特定方案的特定页面时(通过scheme_assignment),我有一些SQL正在工作:
Page.find_by_sql("
SELECT pages.id
FROM pages
INNER JOIN scheme_assignments ON (scheme_assignments.schemable_type = 'Page' AND
scheme_assignments.schemable_id = pages.sid)
INNER JOIN schemes ON (schemes.sid = scheme_assignments.scheme_id AND
schemes.sid IN (4,6,7))
GROUP BY pages.id")
Run Code Online (Sandbox Code Playgroud)
当我试图将其转换为ARel时:
Page.select("pages.id")
.joins("scheme_assignments")
.on("scheme_assignments.schemable_type = 'Page' AND scheme_assignments.schemable_id = pages.sid")
.joins("schemes")
.on("schemes.sid = scheme_assignments.scheme_id AND schemes.sid IN (1)")
.group("pages.id")
Run Code Online (Sandbox Code Playgroud)
我会得到这个错误:NoMethodError: undefined methodjoin_sql'for"schemes":String`
怎么会?是因为它不是我Page模型中的关联吗?可以在没有在模型中创建关联的情况下将SQL转换为ARel吗?
给定这个 svg:
<svg width="640" height="480" xmlns="http://www.w3.org/2000/svg">
<!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->
<g>
<title>Layer 1</title>
<ellipse stroke="#000000" ry="210.999999" rx="259.000004" id="svg_1" cy="237.727263" cx="324.999989" stroke-width="5" fill="#FF0000"/>
</g>
</svg>
Run Code Online (Sandbox Code Playgroud)
如何将其缩放到用户 320x240 而无需重新计算内部数字?这可能吗?