小编Mat*_*iby的帖子

ruby sftp错误

我正在尝试使用ruby将文件上传到我的sftp并且我可以ssh并且一切都很好但是我的脚本失败了....这是我的小脚本

require 'rubygems'
require 'net/sftp'

Net::SFTP.start('50.5.54.77', 'root', :password => 'PASSWORD') do |sftp|
  # upload a file or directory to the remote host
  sftp.upload!("/Users/tamer/sites/sandbox/move_me.txt", "/home")
end
Run Code Online (Sandbox Code Playgroud)

但我一直收到这个错误

 ruby sftp.rb 
/Library/Ruby/Gems/1.8/gems/net-sftp-2.0.5/lib/net/sftp/operations/upload.rb:313:in `on_open': 
Net::SFTP::StatusException open /srv (4, "failure") (Net::SFTP::StatusException)
Run Code Online (Sandbox Code Playgroud)

我有什么不妥的想法

ruby scripting sftp ruby-on-rails

8
推荐指数
1
解决办法
7448
查看次数

这个红宝石做了什么?

unless (place =~ /^\./) == 0
Run Code Online (Sandbox Code Playgroud)

我知道除非是喜欢if not但是这个条件呢?

ruby ruby-on-rails

7
推荐指数
2
解决办法
481
查看次数

Ruby group_by对象?

我有一个数组或不同的对象,我想按对象分组.例如

 => [#<Graphic id: 3...">, #<Collection id: 1....">, #<Category id:...">, #<Volume id: 15...">] 
 all.size
 => 4 
Run Code Online (Sandbox Code Playgroud)

我试过了

all.group_by(Object) 
Run Code Online (Sandbox Code Playgroud)

但这没有用......关于如何在一个数组中分组对象的任何想法?

ruby arrays grouping ruby-on-rails ruby-on-rails-3

7
推荐指数
1
解决办法
9732
查看次数

在回调中发送$(this)

我有这个jQuery点击事件

$('#sidebar .nav a span').click(function () {
  var sidebar_nav = $(this);
  $("#main").load("type_change.php?id="+id, successCallback);
Run Code Online (Sandbox Code Playgroud)

然后我有回调来做绑定

var successCallback = function(responseText, textStatus, XMLHttpRequest) {
  //doing all the binding in here
}
Run Code Online (Sandbox Code Playgroud)

有没有办法传递$(this)或者传递sidebar_navsuccessCallback函数,所以我可以用它做点什么

jquery

7
推荐指数
1
解决办法
235
查看次数

名称中的空格正在打破下载?

好的,所以我有这个代码,允许用户下载一首歌

$file = DIR_DOWNLOAD . $download_info->row['filename'];
$mask = basename($download_info->row['mask']);
$mime = 'application/octet-stream';
$encoding = 'binary';

if (!headers_sent()) {
if (file_exists($file)) {
    header('Pragma: public');
    header('Expires: 0');
    header('Content-Description: File Transfer');
    header('Content-Type: ' . $mime);
    header('Content-Transfer-Encoding: ' . $encoding);
    header('Content-Disposition: attachment; filename=' . ($mask ? $mask : basename($file)));
    header('Content-Length: ' . filesize($file));
    $file = readfile($file, 'rb');
Run Code Online (Sandbox Code Playgroud)

问题是,如果歌曲中有一个空格,就像sinsita happy 1 SONIFI.mp3用户只会下载一个名为的文本文件sinsita...任何想法如何解决这个问题

php header file download pragma

7
推荐指数
1
解决办法
2453
查看次数

rake db:migrate不能在我的postgres db上运行

好吧,所以我有一个rails应用程序,我试图在postgres数据库上运行迁移,我通常使用mysql,一切都很好,但当我运行命令,我得到这个

rake db:migrate
(in /Users/tamer/Sites/my_app)
/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:487: [BUG] Segmentation fault
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]

-- control frame ----------
c:0058 p:---- s:0215 b:0215 l:000214 d:000214 CFUNC  :exec
c:0057 p:0040 s:0211 b:0211 l:000191 d:000210 BLOCK  /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter
c:0056 p:0005 s:0208 b:0208 l:000198 d:000207 BLOCK  /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract_adapter.r
c:0055 p:0032 s:0206 b:0206 l:000205 d:000205 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activesupport-3.0.3/lib/active_support/notifications/instrumenter.rb:21
c:0054 p:0052 s:0199 b:0199 l:000198 d:000198 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract_adapter.r
c:0053 p:0018 s:0192 b:0192 l:000191 d:000191 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter
c:0052 p:0013 s:0187 b:0187 l:000186 d:000186 METHOD /Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter
c:0051 p:0011 s:0184 b:0184 l:000183 …
Run Code Online (Sandbox Code Playgroud)

ruby database postgresql ruby-on-rails ruby-on-rails-3

7
推荐指数
1
解决办法
3744
查看次数

警卫为何停止?

我有一个rails应用程序,我只是把守卫和minitest和我的gaurd文件

guard 'minitest', :cli => '--drb --format doc --color' do
  # with Minitest::Unit
  watch(%r|^test/(.*)\/?test_(.*)\.rb|)
  watch(%r|^lib/(.*)([^/]+)\.rb|)     { |m| "test/#{m[1]}test_#{m[2]}.rb" }
  watch(%r|^test/test_helper\.rb|)    { "test" }

  # Rails
  watch(%r|^app/controllers/(.*)\.rb|) { |m| "test/functional/#{m[1]}_test.rb" }
  watch(%r|^app/helpers/(.*)\.rb|)     { |m| "test/helpers/#{m[1]}_test.rb" }
  watch(%r|^app/models/(.*)\.rb|)      { |m| "test/unit/#{m[1]}_test.rb" }  
end
Run Code Online (Sandbox Code Playgroud)

但是当我跑卫时,我得到一个命令提示符

bundle exec guard
22:14:12 - INFO - Guard uses TerminalTitle to send notifications.
22:14:12 - INFO - Guard is now watching at '/Users/trace/Sites/application'
1.9.3 (main):0 > 2 + 2
=> 4
Run Code Online (Sandbox Code Playgroud)

我为什么得到这个提示.任何想法......这里是我正在使用的一些宝石

更新中...

当我跑步all minitest然后测试运行...但为什么我必须运行...任何想法

ruby ruby-on-rails guard minitest ruby-on-rails-3

7
推荐指数
1
解决办法
2144
查看次数

PHP md5解释道

我正在研究这个PHP项目,我有很多地方正在使用md5.我甚至多次使用它,但是今天我还不清楚它的功能是什么.我意识到它会解密传入的值但是如何撤消它以使其恢复原状.也许我不清楚整个过程,如果有人有关于这个过程的信息我会非常感激

php md5

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

为什么卡皮斯特拉诺表现得像这样?

我的部署问题

我跑了帽子部署并得到了这个

 Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.
** [174.143.150.79 :: out] Permission denied (publickey).
** fatal: The remote end hung up unexpectedly
command finished
*** [deploy:update_code] rolling back
* executing "rm -rf /home/deploy/transprint/releases/20110105034446; true"
servers: ["174.143.150.79"]
[174.143.150.79] executing command
Run Code Online (Sandbox Code Playgroud)

这是我的deploy.rb

set :application, "transprint"
set :domain, "174.149.150.79"
set :user, "deploy"
set :use_sudo, false
set :scm, :git
set :deploy_via, :remote_cache

set :app_path, "production"
set :rails_env, 'production'


set :repository,  "git@github.com:myname/something.git"
set :scm_username, 'deploy'

set :deploy_to, "/home/deploy/#{application}"

role …
Run Code Online (Sandbox Code Playgroud)

ruby deployment capistrano ruby-on-rails

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

如何将auto_increment添加到SQL Server 2008中的列

我使用的是SQL Server 2008,我使用的数据库表的主键不是IDENTITY列(不确定原因).我需要改变它.

我在设计视图中的SQL Server Management Studio中,在列属性下,由于某种原因我无法更改标识规范Yes.

有没有我失踪的东西..我是SQL Server的新手 - 关于我所缺少的任何想法?

这是创建表

CREATE TABLE [dbo].[AR_Transactions](
       [Trans_ID] [bigint] NOT NULL,
       [DateTime] [datetime] NOT NULL,
       [Cashier_ID] [nvarchar](50) NULL,
       [CustNum] [nvarchar](12) NOT NULL,
       [Trans_Type] [nvarchar](2) NOT NULL,
       [Prev_Cust_Balance] [money] NULL,
       [Prev_Inv_Balance] [money] NULL,
       [Trans_Amount] [money] NOT NULL,
       [Payment_Method] [nvarchar](4) NULL,
       [Payment_Info] [nvarchar](20) NULL,
       [Description] [nvarchar](38) NULL,
       [Invoice_Number] [bigint] NOT NULL,
       [Store_ID] [nvarchar](10) NOT NULL,
       [Dirty] [bit] NOT NULL,
       [Station_ID] [nvarchar](5) NULL,
       [Payment_Type] [smallint] NULL,

CONSTRAINT [pkAR_Transactions] 
       PRIMARY KEY CLUSTERED([Store_ID] …
Run Code Online (Sandbox Code Playgroud)

sql auto-increment sql-server-2008

6
推荐指数
3
解决办法
2万
查看次数