草庐IT

client_address

全部标签

ruby-on-rails - Rails GeoCoder,循环遍历现有数据库和 geocode_by :address, :city, :state

我已经导入了一个包含10,000个位置的.csv文件,我需要遍历数据库和geocode_by几个字段而不是通常的“geocode_by:address”我正在使用地理编码器gem。我的数据库方案是这样的create_table"locations",:force=>truedo|t|t.string"Address"t.string"City"t.string"State"t.string"Zip"t.float"latitude"t.float"longitude"t.datetime"created_at"t.datetime"updated_at"end我可以在Controlle

Ruby 2.0p0 和 XMLRPC::Client

我在使用Ruby2.0p0和XMLRPC::Client时遇到问题。当我在2个不同版本的ruby​​中运行下面的代码时,我在1.9.3上得到了正确的响应,但在2.0.0上得到了错误。有同样问题的人吗?解决方案是不使用最新版本的ruby​​还是有解决方法?require"xmlrpc/client"server=XMLRPC::Client.new2('http://api.flickr.com/services/xmlrpc/')beginres=server.call('flickr.test.echo')putsresrescueXMLRPC::FaultException=>ep

ruby - 如何修复错误 : "\xC3" on US-ASCII when bootstrapping chef-client?

我有一台运行RHEL5.10且带有最新补丁的Chef服务器和客户端虚拟机。当我尝试用knifebootstrapnodename-Nnodename-xroot-Ppassword我收到以下错误,这会阻止在服务器上填充我的自动属性。nodenameConverging0resourcesnodenamenodenameRunninghandlers:nodename[2014-07-25T14:46:40-04:00]ERROR:RunningexceptionhandlersnodenameRunninghandlerscompletenodenamenodename[2014-07

ruby - 使用rest-client ruby​​ gem在elasticsearch中传递json数据获取请求

如何使用rest客户端执行以下查询(在doc中给出)。curl-XGET'http://localhost:9200/twitter/tweet/_search'-d'{"query":{"term":{"user":"kimchy"}}}'我试过这样做:q='{"query":{"term":{"user":"kimchy"}}}'r=JSON.parse(RestClient.get('http://localhost:9200/twitter/tweet/_search',q))这引发了一个错误:in`process_url_params':undefinedmethod`del

ruby - 从 Addressable 对象中获取完整的 URI?

如果我有一个这样的可寻址对象:uri=Addressable::URI.parse("http://example.com/path/to/resource/")我如何找回“http://example.com/path/to/resource/”——我查看了uri.methods,但我看不出我应该使用哪一个来找回完整的URI。 最佳答案 使用to_s方法:uri=Addressable::URI.parse("http://example.com/path/to/resource/")uri.to_s#=>"http://exam

ruby-on-rails - rails : Setting locale appropriately to IP address

我正在尝试使用request.location(geocodergem),将区域设置适本地设置为客户端IP地址。这是我得到的:app/controllers/application_controller.rbbefore_action:set_localeprivatedefset_locale#getlocationwithgeocoderlocation=request.location#setlocalethroughURLifparams.has_key?(:locale)I18n.locale=params[:locale]||I18n.default_locale#setl

ruby - 使用ruby google-api-client获取youtube视频数据

您好!我看过很多类似的问题,但想不通为什么没有一个能给出明确的答案。我正在尝试使用google-api-clientgem连接到youtube数据api,以从youtube视频链接中检索缩略图。我假设我不需要处理那个(对我来说晦涩难懂)oAuth身份验证。第一步:我使用googleapi控制台创建项目,授权Youtube数据API。在“API访问”选项卡中,我选择“创建客户端ID...”和选项“服务帐户”。它给了我一个客户端ID、电子邮件地址和公钥指纹。第二:我使用google-api-clientgem创建我的ruby​​脚本。我只是复制/粘贴文档中的示例:需要“google/api

ruby - Capybara-webkit、rspec 集成规范和 xvfb : webkit_server: Fatal IO error: client killed

我正在尝试使用headless(headless)gem、xvfb和用于headless(headless)测试的capybara-webkit来获得在ubuntu服务器CI盒上运行的一套集成规范。一切都在本地开发箱上运行良好,但一旦转移到CI服务器,事情就会变得有趣。在规范助手中有一些代码包装:js在headless(headless)block中启用集成规范,如下所示:config.around(:each,:js=>true)do|example|Headless.ly&exampleend就像我说的,这一切都在本地开发箱上运行良好。在CI上,它使用headless(headle

ruby-on-rails - rails : correct redirect but incorrect URL in address bar after creating into DB

在我的Rails应用程序中,我有一个这样的创建按钮defcreate@client=Client.find(params[:client_id])@inventory=@client.inventories.create(params[:inventory])redirect_toclient_path(@client)end创建库存时(作为客户端的一部分,例如客户端有很多库存,库存属于客户端),库存被添加到数据库中的客户端,并重定向到localhost:3000/client/(无论是客户ID是)但是,我的程序有问题,因为尽管它进行了正确的重定向,但在我推送创建后地址栏中的地址是lo

ruby-on-rails - 如何使用 rest-client gem 发送 header 和 cookie

在代码中,我试图在同一个请求中发送header和cookie下面是代码@result=RestClient.post('url',{:billingSourceCode=>"code"},{:cookies=>{:session_id=>"1234"}},{:headers=>{'Content-Type'=>'application/json',"Authorization"=>"key","Accept"=>"application/json"}})我收到以下错误信息ArgumentError(wrongnumberofarguments(4for3)):