使用WSL时如何从Windows访问Linux二进制文件?

我正在尝试使用新的Windows Windows系统Linux作为在Windows中开发Rails应用程序的方法。 我安装了WSL并且我有Ruby,但是如何从Windows GUI应用程序中使用Ruby,特别是RubyMine: 这样我就可以轻松启动rails,运行测试等。

可以在没有安装nokogiri-java的情况下在jruby中加载nokogiri?

我需要一种方法来运行以下nokogiri脚本 #parser.rb require ‘nokogiri’ def parseit() //… end 并在jruby中的main.rb下运行时调用parseit() #main.rb require ‘parser’ parseit() 当然问题是jruby找不到’nokogiri’因为我还没有安装它nokogiri-java通过jruby -S gem install nokogiri 原因是我在Jruby下运行的nokogiri中发现了一些错误,所以我只在Ruby上安装了nokogiri而不是Jruby。 parser.rb在Ruby下完美运行。 所以我的目标是能够运行parseit()而无需在Jruby上安装nokogiri!

Btrieve / Pervasive db和Ruby

有没有任何解决方案可以与Ruby级别的Btrieve / Pervasive db一起使用? 有gem吗? 也许有人对这样的事情有一些经验? 或者也许通过Jruby使用一些Java库? 我从未使用过Jruby

如何拆分字符串并跳过空格?

我有一个像” This is a test “的字符串。 我想用空格字符分割字符串。 我是这样做的: puts ” This is a test “.strip.each(‘ ‘) {|s| puts s.strip} 结果是: 这个 是 一个 测试 这是一个测试 为什么最后一行”This is a test” ? 我需要的是,如果两个单词之间有两个或更多空格字符,那么这不应该返回“行”。 我只想得到在给定字符串中分割的单词。 有没有人有想法?

Rails Paperclip:有没有选项将上传的文件保存在公共文件夹之外?

我正在使用paperclip gem进行上传。 我想将上传的文件/图像保存在公共文件夹之外。 如果您有任何想法请分享。

使用Ruby gsub转义linux路径名中的空格

我试图逃避Linux路径中的空间。 但是,每当我试图逃避反斜杠时,我最终都会出现双斜线。 示例路径: /mnt/drive/site/usa/1201 East/1201 East Invoice.pdf 所以我可以在Linux中使用它我想逃避它: /mnt/drive/site/usa/1201\ East/1201\ East\ Invoice.pdf 所以我正在尝试这个: backup_item.gsub(“\s”, “\\\s”) 但是我得到了意想不到的输出 /mnt/drive/site/usa/1201\\ East/1201\\ East\\ Invoice.pdf

undefined方法`’为nil:NilClass for Rails模型为new

我有一个模特学生和一个控制器学生。 在控制器中我有一个新方法 def new @student = Student.new end 然后我有一个/views/students/new.html.haml使用@student吓坏了。 我收到了错误 undefined method `[]’ for nil:NilClass 这是它的haml %h1 Students#new %p Find me in app/views/students/new.html.haml = form_for(@student) do |f| = f.text_field :email = f.button “Submit” 如果我用Student.new替换@student,我会得到相同的结果。 但是,如果我启动服务器new并且只是使用 = Student.new 我会得到这个输出 # 如果我进入rails控制台,我可以乱用学生并使用Student.new和Student.all等。 有谁知道发生了什么或我做错了什么? 这是我加载localhost:3000 / students / new时的错误日志 Started GET “/students/new” for 127.0.0.1 at 2014-01-22 20:53:50 -0600 […]

Webrick透明代理

我有一个绝对简单的代理运行。 require ‘webrick’ require ‘webrick/httpproxy’ s = WEBrick::HTTPProxyServer.new(:Port => 8080, :RequestCallback => Proc.new{|req,res| puts req.request_line, req.raw_header}) # Shutdown functionality trap(“INT”){s.shutdown} # run the beast s.start 在我看来,这应该不会以任何方式影响沟通。 但是有些网站不再有用了。 特别是http://lastfm.de的嵌入式闪存播放器不起作用。 标题看起来链接: – -> http://ext.last.fm/2.0/?api%5Fsig=aa3e9ac9edf46ceb9a673cb76e61fef4&flashresponse=true&y=1269686332&streaming=true&playlistURL=lastfm%3A%2F%2Fplaylist%2Ftrack%2F42620245&fod=true&sk=ee93ae4f438767bf0183d26478610732&lang=de&api%5Fkey=da6ae1e99462ee22e81ac91ed39b43a4&method=playlist%2Efetch GET http://play.last.fm/preview/118270350.mp3 HTTP/1.1 Host: play.last.fm User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2) Gecko/20100308 Ubuntu/10.04 (lucid) Firefox/3.6 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: de,en-us;q=0.7,en;q=0.3 Accept-Encoding: gzip,deflate […]

OptionParser返回bool而不是参数?

当我从OptionParser文档中运行此示例时 : require ‘optparse’ options = {} OptionParser.new do |opts| opts.banner = “Usage: example.rb [options]” opts.on(“-v”, “–[no-]verbose”, “Run verbosely”) do |v| options[:verbose] = v end end.parse! p options p ARGV 并输入: ruby test.rb -v 100 ,它返回: {:verbose=>true} [“100”] 不应该是100 ,而不是布尔值? 我不知道这个,有没有人有任何建议?

Rails:从多个模型创建“所有活动源”

我有一个页面有几个“Feeds”。 在我的控制器中我有这样的事情: def index @plays = current_user.plays.includes(:game).order(“created_at desc”) @wants = current_user.wants.includes(:game).order(“created_at desc”) @ratings = current_user.ratings.includes(:game).order(“created_at desc”) end 我在视图中使用这样的代码: You played 现在,我想在“所有活动”页面上进行第四次提要,该页面在按创建日期(desc)排序的一个Feed中显示“播放”,“想要”和“评级”。 任何有关最佳方法的帮助都会很棒。 更新:从每个模型请求的代码,现在很好,很简单: class Play < ActiveRecord::Base attr_accessible :game_id, :user_id, :description belongs_to :user belongs_to :game end class Rating < ActiveRecord::Base attr_accessible :game_id, :id, :score, :user_id, :description belongs_to :user belongs_to :game end class Want < ActiveRecord::Base […]