最近在熟悉Mocha javascript测试框架的过程中,遇到了这个我不明白的部分:
生成文件
善良一点,不要让开发人员在你的文档中寻找如何运行测试,在你的 Makefile 中添加一个 make test 目标:
test:
./node_modules/.bin/mocha --reporter list
.PHONY: test
Run Code Online (Sandbox Code Playgroud)
这几乎没有描述性,如果您不知道 makefile 是什么,也不是很有帮助。
那么,什么是 Makefile?它与 Gruntfile 或使用有什么不同npm run?
我在使用嵌套属性创建多个模型对象时遇到问题.形式.erb我有:
<%= f.fields_for :comments do |c| %>
<%= c.text_field :text %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
正在生成如下所示的输入字段:
<input type="text" name="ad[comments_attributes][0][text]" />
<input type="text" name="ad[comments_attributes][1][text]" />
<input type="text" name="ad[comments_attributes][2][text]" />
Run Code Online (Sandbox Code Playgroud)
当我真正想要的是它看起来像这样:
<input type="text" name="ad[comments_attributes][][text]" />
<input type="text" name="ad[comments_attributes][][text]" />
<input type="text" name="ad[comments_attributes][][text]" />
Run Code Online (Sandbox Code Playgroud)
使用表单助手,如何让表单创建像第二个示例中的哈希数组,而不是像第一个那样使用哈希哈希?
我已经使用PhoneGap 1.0很长一段时间了,它在模拟器和我的设备上没有问题.(即我做了配置文件等)现在我正在尝试使用Phonegap/Cordova 1.7进行相同的操作,并且在模拟器上构建成功,但在配置的测试设备(iPhone 3GS - iOS 4.3)上没有.无法弄清楚发生了什么.这是一个干净的新项目.
我在构建失败时收到的错误消息是:
Command /usr/bin/lipo failed with exit code 1
我试过firefox,chrome和mobile safari.当我向列表中添加data-inset ="true"时,它将正确地围绕列表的角落,但它不会在任何一侧添加1em余量.我无法弄清楚这一点.它甚至可以在一个简单的样板页面上进行,除了列表之外没有任何内容.例如:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.js"></script>
</head>
<body>
<ul data-role="listview" data-theme="c" data-inset="true">
<li><a href="#">first</a></li>
<li><a href="#">second</a></li>
</ul>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
没有正确显示.谢谢你的帮助.
我有两张桌子:
Users
=====================================
id, name, country_id, nationality_id
Countries
=====================================
id, name, currency
Run Code Online (Sandbox Code Playgroud)
country_id并且nationality_id都使用Countries表中的id.
country_id而nationality_id不一定是相同的.
我想得到的是一个表格,其中包含给定国家/地区的每个用户的名称,他们所在国家/地区的名称nationality_id以及他们使用的货币country_id.
我的问题是如何做WHERE子句.这就是我所拥有的,但它是不正确的,因为货币由nationality_id而不是代替country_id.
希望有道理......
SELECT
Users.name,
Countries.name,
Countries.currency
FROM
Users, Countries
WHERE
Users.nationality_id = Countries.id
AND Countries.id = 6
Run Code Online (Sandbox Code Playgroud) 我想做这样的事情:
SELECT
Users.id,
Countries.name
FROM
Users, Countries
WHERE
Users.country_id = Countries.id
Run Code Online (Sandbox Code Playgroud)
问题是Users.country_id有时可以NULL,如果是整个行都没有返回.我希望它返回行但在该列中使用'null'或''.我试过这个:
SELECT
Users.id,
Countries.name
FROM
Users, Countries
WHERE
(Users.country_id = Countries.id OR Users.country_id IS NULL)
Run Code Online (Sandbox Code Playgroud)
但是,对于存在的每个*Countries.id*,它返回一次行.我该如何解决这个问题?