创建Compass项目时的问题(EACCES on line )

我在创建新的罗盘项目时遇到了问题(Windows 7)。 我明白了: C:\>compass create a create config.rb Errno::EACCES on line [“891”] of C: Permission denied – (C:/a/config.rb20140321-6828-1g0ytlc, C:/a/config.rb) Run with –trace to see the full backtrace 我试图用“以管理员身份运行”启动cmd,我试图删除指南针,sass和ruby,并重新安装,没有任何运气。 是否有其他人遇到问题或知道解决这个棘手的问题?

在Ruby on Rails中在运行时构建表

如果rails希望从模型名称推断表名,我将如何在运行时创建多个使用相同模型的数据库表? 我希望能够基于模型创建新对象,然后创建一个具有该对象将引用的唯一名称的新表。 有没有人可以分享任何示例或建议来帮助我找到解决方案?

Ruby用逗号分隔吸收尾随空格

我需要将一个字符串拆分为两个变量。 例如,以下方法可以正常工作: first,second = “red,blue”.split(‘,’) 我想分割用户输入,可能在逗号后面有一个可选空格。 如何在逗号被吸收后写入空格? 我需要正确处理所有这些可能性: “red,blue” # first=”red” second=”blue” “red, blue” # first=”red” second=”blue” “red,dark blue” # first=”red” second=”dark blue” “red, light blue” # first=”red” second=”light blue”

剥去特定控制字符的ruby字符串

这很简单:如何删除特殊字符的ruby字符串? 这是字符: http : //www.fileformat.info/info/unicode/char/2028/index.htm 这是字符串,句点和结尾引号之间有两个特殊字符: “Each of the levels requires logic, skill, and brute force to crush the enemy. ” 我没试成功: string.gsub!(/[\x00-\x1F\x7F]/, ”) 和gsub(“/\n/”, “”) 我正在使用ruby 1.9.3p125

我如何逐行使用Ruby将csv转换为数组?

输入文件如下: 狗,白,男性 猫,紫,女 大鼠,灰色,男性 我希望逐行完成并对数据做一些事情。 File.open(“animals.csv”) while file has next line currentline = array with each cell being an entry in the array if currentline[0] == dog put “dogs are cool” end put “your animal is a ” + currentline[0] end 你明白了,对吗? 我想用ifs和whatnot操纵数据线,并在最后打印出来。 谢谢

Rails活动记录查询获取最常见的对象

我正在尝试查询模型以获得某个属性的最常见字段 Person.maximum(‘age’) 但是,如何查询一组让我们说最常见的6个年龄段。 任何帮助将非常感激。 谢谢

为什么Ruby使用nil命名空对象?

谷歌搜索但没有找到答案。 名称为nil有什么特别之处吗? nil的概念与其他语言中的null不同吗?

Ruby HTTP Library通过Facebook App获得Connection Reset

以下curl命令按预期工作: curl ‘https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=myappid&client_secret=myclientsecret’ 我想在我的Ruby程序中做同样的事情。 以下代码给出了一个错误: fb_access_token_url = URI.parse( ‘https://graph.facebook.com/oauth/access_token’ + ‘?grant_type=client_credentials’ + ‘&client_id=’ + FACEBOOK_APP_ID + ‘&client_secret=’ + FACEBOOK_APP_SECRET) fb_access_token = Net::HTTP.get(fb_access_token_url) 这段代码也是如此: fb_access_token_host = ‘graph.facebook.com’ fb_access_token_path_and_params = ( ‘/oauth/access_token’ + ‘?grant_type=client_credentials’ + ‘&client_id=’ + FACEBOOK_APP_ID + ‘&client_secret=’ + FACEBOOK_APP_SECRET) https_port = Net::HTTP.https_default_port() fb_access_token = Net::HTTP.get_response(fb_access_token_host, fb_access_token_path_and_params, https_port) 错误如下: Errno::ECONNRESET: Connection reset by peer /usr/lib/ruby/1.8/net/protocol.rb:135:in […]

没有路线匹配…… Rails引擎

所以我一直收到错误: No route matches {:action=>”create”, :controller=>”xaaron/api_keys”} 测试中抛出了哪些内容: it “should not create an api key for those not logged in” do post :create expect(response).to redirect_to xaaron.login_path end 当我去spec/dummy并运行rake routes命令时,我看到: api_keys GET /api_keys(.:format) xaaron/api_keys#index POST /api_keys(.:format) xaaron/api_keys#create new_api_key GET /api_keys/new(.:format) xaaron/api_keys#new edit_api_key GET /api_keys/:id/edit(.:format) xaaron/api_keys#edit api_key GET /api_keys/:id(.:format) xaaron/api_keys#show PATCH /api_keys/:id(.:format) xaaron/api_keys#update PUT /api_keys/:id(.:format) xaaron/api_keys#update DELETE /api_keys/:id(.:format) […]

将文本粘贴到IRB非常慢。 Readline问题?

当我将以下文本粘贴到在ruby-enterprise-2011.03下运行的IRB或PRY时,需要13秒。 # Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 在同一台计算机上运行irb与其他ruby安装时,粘贴速度并不慢。 jruby-1.5.6 jruby-1.6.3 ruby-1.8.6-p420 ruby-1.8.7-p352 ruby-1.9.1-p431 ruby-1.9.2-p290 ruby-1.9.3-preview1 or Mac OS X’s default system install of 1.8.7-p249 这个问题与Rails控制台在编辑文本时运行速度非常慢有关,但我没有使用rvm,在编写,编辑或删除文本时没有慢; 只有粘贴很慢。 @ fl00r的建议有效,但这不是永久修复。 此外,如果粘贴文本中有硬新行,则只有最后一行很慢。 例如,粘贴以下文本仅需约1.5秒 # Lorem ipsum dolor sit amet, consectetur adipisicing elit, # sed […]