小编Sco*_*hea的帖子

如何使用Perl列出目录中的所有文件?

Perl中是否有一个列出目录中所有文件和目录的函数?我记得Java有File.list()这个吗?在Perl中是否有类似的方法?

directory perl

53
推荐指数
5
解决办法
11万
查看次数

警告:已初始化常量PDF

现在我正在使用rails 3.0.0.如果我在终端中运行我的项目,我会收到此警告.请帮我.

/usr/share/ruby-rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.0/lib/action_dispatch/http/mime_type.rb:98:警告:已经初始化的常量PDF

rubygems ruby-on-rails-3 rails-3-upgrade wicked-pdf

31
推荐指数
2
解决办法
8659
查看次数

Rails 3.1 Errno :: EACCES权限被拒绝

Rails 3.1 Apache开发环境中的Passenger当我去访问路由的索引(即GET)时,我得到:

Errno::EACCES in Crb_agendas#index

Showing /var/www/crbagenda/app/views/layouts/application.html.erb where line #5 raised:

Permission denied - /var/www/crbagenda/tmp/cache/assets/E2C

Extracted source (around line #5):

2: <html>
3: <head>
4:   <title>CrbAgendas</title>
5:   <%= stylesheet_link_tag "application" %>
6:   <%= javascript_include_tag "application" %>
7:   <%= csrf_meta_tags %>
8: </head>

Rails.root: /var/www/crbagenda
Run Code Online (Sandbox Code Playgroud)

当我进入提到的路径(/ var/www/crbagenda/tmp/cache/assets/E2C)时,没有E2C文件夹和root(运行的是什么apache)拥有资产目录...不确定我做错了什么在这....或者我可以展示什么来帮助.

ruby-on-rails-3.1

23
推荐指数
5
解决办法
6万
查看次数

Ruby将字符串转换为文件

是否可以将字符串转换为文件而不将其写入磁盘?

我想无处不在地使用一个文件串:

input = "123"
if (ARGV.length == 1)
   input = File.open(ARGV[0])

   #do stuff with input
end
Run Code Online (Sandbox Code Playgroud)

我可以从字符串创建文件(无需写入磁盘)吗?否则,input.readline()当它是一个字符串时,我将无法做到.

ruby string file

12
推荐指数
2
解决办法
9063
查看次数

如何在Ember.Object中创建私有方法/属性?

我们可以像这样创建Em.Object:

var foo = Em.Object.create({
   somevar : '123'
});
Run Code Online (Sandbox Code Playgroud)

然后使用它:

foo.get('somevar');
Run Code Online (Sandbox Code Playgroud)

但是如何在Em.Object中创建一个私有属性或方法,可以从对象访问但不是我们的?

ember.js

12
推荐指数
2
解决办法
4692
查看次数

如何使用RestClient进行Rails基本授权?

我正在尝试使用rest-client向REST服务(HP ALM 11 REST API fwiw)发布请求并继续获取未经授权的响应.可能是我没有正确地遵循文档,但我也不确定我正在正确地处理标题.到目前为止,我在Google上搜索RestClient一直没有结果.任何帮助,将不胜感激:

码:

@alm_url       = "http://alm_url/qcbin/"
@user_name     = "username"
@user_password = "password"

authentication_url = @alm_url + "rest/is-authenticate"
resource = RestClient::Resource.new authentication_url
resource.head :Authorization => Base64.encode64(@user_name) + ":" + Base64.encode64(@user_password)
response = resource.get


#response = RestClient.get authentication_url, :authorization => @username, @user_password
Rails.logger.debug response.inspect
Run Code Online (Sandbox Code Playgroud)

基于这个SO问题,我也尝试了以下但没有成功:

@alm_url       = "http://alm_url/qcbin/"
@user_name     = "username"
@user_password = "password"

authentication_url = @alm_url + "rest/is-authenticate"
resource = RestClient::Resource.new authentication_url, {:user => @user_name, :password => @user_password}
response = resource.get


#response = RestClient.get authentication_url, …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails rest-client ruby-on-rails-3.1

6
推荐指数
1
解决办法
5642
查看次数

Rails 3 - 通过关联在has_many上的where子句

嗨,您好,

我对has_many的查询有一点问题:通过关联......

我的设置如下:

PurchaseOrderAddressAssignment:

belongs_to :address

belongs_to :purchase_order
Run Code Online (Sandbox Code Playgroud)

地址:

has_many :purchase_order_address_assignments

has_many :purchase_orders, :through => :purchase_order_address_assignments
Run Code Online (Sandbox Code Playgroud)

采购订单:

has_many :purchase_order_address_assignments

has_many :addresses, :through => :purchase_order_address_assignments
Run Code Online (Sandbox Code Playgroud)

我的where子句:

PurchaseOrder.where("addresses.id = 168 and addresses.id = 169").includes(:addresses)
Run Code Online (Sandbox Code Playgroud)

返回0记录......但应该至少有1 ...

PurchaseOrder.where(:baan_id => "KD0005756").first.address_ids
Run Code Online (Sandbox Code Playgroud)

正在返回[168,169,170,327]

......我觉得我太傻了解决这个小问题: - /

谁能告诉我这里我做错了什么?

谢谢,

迈克尔

activerecord ruby-on-rails ruby-on-rails-3

6
推荐指数
1
解决办法
5277
查看次数

在Rails中运行bundle exec rspec spec/requests/static_pages_spec.rb时出错

我下面这篇文章中,我可以在下面和主页这个ruby文件这样写的代码确实有示例应用程序,但它仍然说静态页面的主页应该有内容"示例应用程序"当我运行 bundle exec rspec spec/requests/static_pages_spec.rb

spec/requests/static_pages_spec文件代码:

require 'spec_helper'

describe "Static pages" do

  describe "Home page" do

    it "should have the content 'Sample App'" do
      visit '/static_pages/home'
      page.should have_content('Sample App')
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

home.html.erb

<h1>Sample App</h1>
<p>
  This is the home page for the
  <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
  sample application.
</p>
Run Code Online (Sandbox Code Playgroud)

下面是我的这个应用程序的宝石文件.请指教.谢谢你的帮助.

source 'https://rubygems.org'

gem 'rails', '3.2.1'
gem 'sqlite3'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development do
gem 'rspec-rails', '2.6.0'

end

group :test do …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1

5
推荐指数
1
解决办法
3098
查看次数

即使使用'autoReconnect = true',MySql JDBC也会超时

有时,我的Java/Tomcat6/Debian Squeeze应用程序无法与MySql服务器通信.Tomcat应用程序位于前端服务器上,而MySql位于单独的MySql-only框中.典型的错误是:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was56588 milliseconds ago.

The last packet sent successfully to the server was 56588 milliseconds ago, which 
is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the
server configured values for client timeouts, or using the Connector/J connection property
 'autoReconnect=true' to avoid this problem.
Run Code Online (Sandbox Code Playgroud)

给出的超时时间仅为60秒,看起来非常短.如果是一个小时或更长时间,我只需设置一个后台任务,每隔几分钟ping一次数据库服务器.我已将autoReconnect参数添加到开始URL,没有明显的影响.

有什么问题在这里吗?谢谢Pat

mysql timeout jdbc

5
推荐指数
1
解决办法
2万
查看次数

卢克说我的Lucene索引目录是无效的

我正在努力了解Lucene,并希望用Luke来研究它.我尝试使用Lucene 4.3中的IndexFiles演示构建索引,然后尝试使用最新版本的Luke查看索引,并且我收到消息:

Invalid directory at the location, check console for more information. Last exception:
org.apache.lucene.index.IndexFormatTooNewException: Format version is not supported (resource: ChecksumIndexInput(MMapIndexInput(path="/home/lavin/sep20.index/segments_2"))): 1 (needs to be between 0 and 0)
Run Code Online (Sandbox Code Playgroud)

任何想法有什么问题以及如何解决?我的Lucene版本对Luke来说是否太新了?有没有办法告诉Lucene写一个旧版索引?提前谢谢, - 马克

lucene luke indexoutofboundsexception

5
推荐指数
1
解决办法
2448
查看次数