我有一个表单选择语句,如下所示:
= f.select :country_id, @countries.map{ |c| [c.name, c.id] }
Run Code Online (Sandbox Code Playgroud)
这导致以下代码:
...
<option value="1">Andorra</option>
<option value="2">Argentina</option>
...
Run Code Online (Sandbox Code Playgroud)
但我想在我的选项中添加自定义HTML属性,如下所示:
...
<option value="1" currency_code="XXX">Andorra</option>
<option value="2" currency_code="YYY">Argentina</option>
...
Run Code Online (Sandbox Code Playgroud) 我有2个哈希,例如:
{'a' => 30, 'b' => 14}
{'a' => 4, 'b' => 23, 'c' => 7}
Run Code Online (Sandbox Code Playgroud)
其中a,b和c都是对象.我怎样才能将这些哈希的密钥加起来得到一个新的哈希:
{'a' => 34, 'b' => 37, 'c' => 7}
Run Code Online (Sandbox Code Playgroud) 默认情况下,gitlab具有以下配置gitlab.yml:
email:
from: notify@gitlabhq.com
host: gitlabhq.com
Run Code Online (Sandbox Code Playgroud)
但是,我需要指定其他变量(主机,端口,用户,密码等)以使用其他邮件服务器.
我怎么做的?
我有这个HTML代码:
<tr>
<td><input type="checkbox" class="chk" /></td>
<td><div class="disabled">text to hide 1</div></td>
<td><div class="disabled">text to hide 2</div></td>
</tr>
Run Code Online (Sandbox Code Playgroud)
我正在使用jQuery来隐藏所有class="disabled"项目:
$("div.disabled").hide() ;
Run Code Online (Sandbox Code Playgroud)
当我单击同一行(tr)中的复选框时,我想显示禁用的div.我试过了
$("input.chk").click(function(){
$(this).parent().parent().(".disabled").show();
}) ;
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
我有一个像这样的对象数组:
Array
(
[945] => member Object
(
[id] => 13317
[name] => Test 999
[last_name] => Test 999
)
[54] => member Object
(
[id] => 13316
[name] => Manuel
[last_name] => Maria parra
)
[654] => member Object
(
[id] => 13315
[name] => Byron
[last_name] => Castillo
)
[656] => member Object
(
[id] => 13314
[name] => Cesar
[last_name] => Vasquez
)
)
Run Code Online (Sandbox Code Playgroud)
我需要根据属性值删除其中一个对象.
例如,我想从数组中删除对象id 13316.
我可以在rails应用程序中获取所有路由吗?我需要一个输出rake routes,并将结果放在一个数组中.
可能吗?怎么样?
运行此查询:
select name from folders order by name
Run Code Online (Sandbox Code Playgroud)
返回这些结果:
alphanumeric
a test
test 20
test 19
test 1
test 10
Run Code Online (Sandbox Code Playgroud)
但我预计:
a test
alphanumeric
test 1
test 10
test 19
test 20
Run Code Online (Sandbox Code Playgroud)
这有什么不对?
我在我的数据库中的"位置"字段中有此URL:
http://www.youtube.com/watch?v=xxxxxxxxxxxxxxxxxxx
Run Code Online (Sandbox Code Playgroud)
我可以得到它@object.location,但我怎样才能得到它的价值v?我的意思是,"xxxxxxxxxxxx"从URL字符串中获取?
对不起我的英语不好...
有一种方法可以知道属性是否有验证?就像是...
Model.attribute.has_presence_validation?
Run Code Online (Sandbox Code Playgroud)
提前致谢.问候.
ruby ×4
attributes ×3
arrays ×2
alphanumeric ×1
git ×1
gitlab ×1
hash ×1
jquery ×1
object ×1
php ×1
postgresql ×1
routes ×1
select ×1
smtp ×1
sorting ×1
sum ×1
url ×1
validation ×1