我有一个Sinatra"hello world"应用程序,我试图使用jRuby运行.它在我运行应用程序时有效,但在我运行机架时则无效.谁能告诉我这里发生了什么?
这是应用程序,在'app.rb'文件中:
require 'rubygems'
require 'bundler/setup'
require 'sinatra'
configure do
set :bind, '0.0.0.0'
end
get '/' do
'Boo!'
end
Run Code Online (Sandbox Code Playgroud)
我可以运行它bundle exec ruby app.rb,它工作正常:
jonea@centos7andy[~/andy/sinatra_sand_jruby]%: bundle exec ruby app.rb
[2015-01-12 10:36:06] INFO WEBrick 1.3.1
[2015-01-12 10:36:06] INFO ruby 1.9.3 (2014-12-09) [java]
== Sinatra/1.4.5 has taken the stage on 4567 for development with backup from WEBrick
[2015-01-12 10:36:06] INFO WEBrick::HTTPServer#start: pid=31654 port=4567
Run Code Online (Sandbox Code Playgroud)
这是我的config.ru来调用上面的程序:
require 'rubygems'
require 'bundler/setup'
require 'sinatra'
require './app'
run Sinatra::Application
Run Code Online (Sandbox Code Playgroud)
如果我运行它,它似乎工作,但我无法使用Web浏览器访问服务器:
jonea@centos7andy[~/andy/sinatra_sand_jruby]%: bundle exec rackup -p4567 …Run Code Online (Sandbox Code Playgroud) 我无法从pg gem获取输入结果.
require 'pg'
require_relative 'spec/fixtures/database'
client = PG.connect( DB[:pg] )
client.type_map_for_queries = PG::BasicTypeMapForQueries.new(client)
client.type_map_for_results = PG::BasicTypeMapForResults.new(client)
client.exec( %|select * from testme;| ) do |query|
query.each {|r| puts r.inspect }
end
Run Code Online (Sandbox Code Playgroud)
该程序给出了输出:
Warning: no type cast defined for type "money" with oid 790. Please cast this type explicitly to TEXT to be safe for future changes.
Warning: no type cast defined for type "numeric" with oid 1700. Please cast this type explicitly to TEXT to be safe for future changes. …Run Code Online (Sandbox Code Playgroud) 我的Centos 7实例上有node和npm.我做了一个
sudo npm -g install coffee
Run Code Online (Sandbox Code Playgroud)
它报告没有错误.但我没有咖啡可执行文件,这是重点.
%: type -a coffee
coffee not found
%: type -a Coffee
Coffee not found
Run Code Online (Sandbox Code Playgroud)
看起来我应该为我的NPM需要一些东西$PATH.如果我知道要添加什么,我会尝试.
对不起,我不知道怎么调试这个.我试过这个:
%: npm bin
/home/jonea/node_modules/.bin
Run Code Online (Sandbox Code Playgroud)
有趣的是,这不是一个存在的目录:
%: ls -la ~/node_modules
total 12
drwxr-xr-x 3 jonea compgen 4096 Jun 6 10:34 .
drwxr-xr-x 33 jonea compgen 4096 Jun 7 09:33 ..
drwxr-xr-x 4 jonea compgen 4096 Jun 6 10:34 coffee
Run Code Online (Sandbox Code Playgroud)
并且,不,该咖啡目录中没有可执行文件.
如果有人对我能做的其他调试有什么想法,我会在这里附上结果.
我有一个包含记录的现有表,我刚刚添加了一个新列ver,我希望它是唯一的。
create table foo (
bar text,
ver integer
);
select * from foo;
bar ver
--- ---
one null
two null
three null
Run Code Online (Sandbox Code Playgroud)
由于某种原因,我正在努力解决如何做到这一点。
我想做类似的事情:
update foo set ver = ( select generate_series(1, 1000) );
Run Code Online (Sandbox Code Playgroud)
或者可能
update foo set ver = v from (select generate_series(1, 1000) as v );
Run Code Online (Sandbox Code Playgroud)
...但当然这些都不起作用。任何人都可以为我指出显而易见的吗?
postgresql ×2
ruby ×2
coffeescript ×1
install ×1
jruby ×1
node.js ×1
rackup ×1
sinatra ×1
sql-update ×1
unique ×1