我正在使用ruby版本1.9.3,我喜欢从下面的视频网址获取主机名,
我试过代码
require 'uri'
url = "https://ferrari-view.4me.it/view-share/playerp/?plContext=http://ferrari-%201363948628-stream.4mecloud.it/live/ferrari/ngrp:livegenita/manifest.f4m&cartellaConfig=http://ferrari-4me.weebo.it/static/player/config/&cartellaLingua=http://ferrari-4me.weebo.it/static/player/config/&poster=http://pusher.newvision.it:8080/resources/img1.jpg&urlSkin=http://ferrari-4me.weebo.it/static/player/swf/skin.swf?a=1363014732171&method=GET&target_url=http://ferrari-4me.weebo.it/static/player/swf/player.swf&userLanguage=IT&styleTextColor=#000000&autoPlay=true&bufferTime=2&isLive=true&highlightColor=#eb2323&gaTrackerList=UA-23603234-4"
puts URI.parse(url).host
Run Code Online (Sandbox Code Playgroud)
它抛出异常URI :: InvalidURIError:错误的URI(不是URI?):
我尝试使用编码URL然后解析如下
puts URI.parse(URI.parse(url)).host
Run Code Online (Sandbox Code Playgroud)
它抛出异常相同 URI::InvalidURIError: bad URI(is not URI?)
但上面的代码适用于以下URL.
url = http://www.youtube.com/v/GpQDa3PUAbU?version=3&autohide=1&autoplay=1
如何解决这个问题?任何建议请.谢谢
我在Boostrap模式对话框中使用tinyMCE4编辑器.当我点击链接图标时,它会打开一个新的模态对话框,它显示正常,但输入区域不可编辑.
<div id="editing" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<form>
<label>
<span>Description</span>
<div id="description"></div>
</label>
<form>
</div>
<script>
tinymce.init({
selector: 'div#description',
inline: false,
theme : "modern",
schema: "html5",
add_unload_trigger: false,
statusbar: false,
plugins: "link",
toolbar: "link | undo redo",
menubar: false
});
</script>
Run Code Online (Sandbox Code Playgroud)

有什么建议
提前致谢
jquery twitter-bootstrap ruby-on-rails-3.2 tinymce-4 tinymce-rails
我可以使用Stripe接收一次性付款而不是定期付款吗?
如果是这样,我必须做什么设置?
我尝试使用Apache SOLR进行搜索.我已经完成了使用apache solr实现的PHP客户端代码.我使用函数solrUpdate索引并使用funcion solrQuery获得搜索结果.
现在我想使用同义词搜索进行搜索,即在之前我将标题索引为"钱"然后,我去搜索关键字是" 钱 ",结果会很顺利.但我想用sysnonym搜索("money"=>"cash"或"currency").
现在我用关键字" 现金 " 搜索没有结果会出现?但我期待只有"钱"的结果将被退回.
我该怎么办?我的xml文档格式为"id"= 123"name"= Money"description"=一些示例说明.
任何想法建议最受欢迎.
Thanx提前.
我有一个数组:
a = ["http://design.example.com", "http://www.domcx.com", "http://subr.com"]
Run Code Online (Sandbox Code Playgroud)
如果该数组中的一个元素与字符串匹配,我想返回true:
s = "example.com"
Run Code Online (Sandbox Code Playgroud)
我试过include?和any?.
a.include? s
a.any?{|w| s=~ /#{w}/}
Run Code Online (Sandbox Code Playgroud)
我不知道如何在这里使用它.有什么建议?
是否可以使用java脚本打开当前活动屏幕的弹出窗口?
var win= window.open(value,'_blank');
Run Code Online (Sandbox Code Playgroud)
上面的脚本在浏览器选项卡中打开弹出窗口但我丢失了活动页面.
有什么建议吗?
提前致谢
解:
按照@Brian的建议,
var win=window.open(value,null,"height=400,width=600,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no");
win.blur();
Run Code Online (Sandbox Code Playgroud)
它适用于IE,FireFox和Safari,但不适用于Chrome浏览器.
任何人都可以建议如何在IE浏览器中打开多个弹出框?上面的脚本只会在IE中打开一个弹出窗口.
我正在使用带有sphinx搜索的rails 2.3.8,在重建索引时收到以下错误消息
indexing index 'model_core'...
collected 882974 docs, 755.7 MB
collected 959418 attr values
sorted 1.9 Mvalues, 100.0% done
**WARNING: sort_hits: merge_block_size=140 kb too low, increasing mem_limit may improve**
Run Code Online (Sandbox Code Playgroud)
这是我的配置文件,
sphinx.yml
development:
port: 9316
test:
port: 9314
production:
port: 9312
Run Code Online (Sandbox Code Playgroud)
请教我如何在sphinx.yml文件中配置?
我是ruby 1.9.2的新手.如何在单个ruby脚本文件中生成CSV文件?
在这里,我写了一个ruby脚本,
require 'rubygems'
require 'pg'
require 'active_record'
require 'csv'
class AttachEmail
def generate_csv
begin
filename = "csvout.csv"
users = User.all
users.each do |u|
products = Product.find(:all,:conditions=>["user_id=?",u.id])
CSV.open(filename, 'w') do |csv|
# header row
user_name = u.name
csv << ['Report']
csv << ['Name','Product', 'Item Count']
products.each do |product|
csv << [user_name, product.title,product.count]
end
end
end
rescue Exception => e
puts e
end
end
generate= AttachEmail.new
generate.generate_csv
Run Code Online (Sandbox Code Playgroud)
当我运行这个脚本.它将产生如下输出,
A B C
0 Report
1 Name,Product,Item Count
2 user1,PD123,10,990
Run Code Online (Sandbox Code Playgroud)
但是我需要输出像,单独的列,请你能帮助我吗?提前致谢