我正试着看看Jruby on Rails上的黄瓜.其中一个预先请求的是webrat,它具有先决条件的hpricot.
我使用hpricot安装了gem:
gem install hpricot --source http://code.whytheluckystiff.net --version 0.6.1 --platform java
这将安装java版本的hpricot.我将hpricot_scan.jar添加到CLASSPATH但是当我运行时:
cucumber features -n
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
HpricotScanService.java:931:in `hpricot_scan': java.lang.NoSuchMethodError:
org.jruby.runtime.builtin.IRubyObject.getInstanceVariable(Ljava/lang/String;)Lorg/jruby/runtime/builtin/IRubyObject;
from HpricotScanService.java:1324:in `__hpricot_scan'
from null:-1:in `call'
from InvocationCallback.java:67:in `execute'
from FullFunctionCallbackMethod.java:69:in `call'
from DynamicMethod.java:243:in `call'
from CachingCallSite.java:283:in `cacheAndCall'
from CachingCallSite.java:121:in `callBlock'
Run Code Online (Sandbox Code Playgroud)
等等
如果我编译HpricotScanService.java文件并将生成的.class文件添加到类路径中,我得到:
Then I should see "Run"
private method `scan' called for Hpricot:Module (NoMethodError)
features/step_definitions/webrat_steps.rb:94:in `/^I should see "([^\"]*)"$/'
features/manage_activity.feature:9:in `Then I should see "Run"'
Run Code Online (Sandbox Code Playgroud)
如果我尝试安装更高版本的hpricot,那么我得到:
ERROR: Failed to build gem native extension.
C:/Program Files/Ruby/jruby-1.2.0/bin/../bin/jruby.bat extconf.rb install …Run Code Online (Sandbox Code Playgroud) 架构:
persons (id, name, birthyear, gender)
pets (id, person_id, name, leg_count)
plants (id, person_id, kind, qty)
我想制作一份关于按人分组的这些事情的只读报告.完成人员列表(没有相关记录).我希望每个人都有"子表".就像是:
Persons
+----+------+-----------+--------+
| id | name | birthyear | gender |
+----+------+-----------+--------+
| 1 | Joe | 1980 | M |
+----+------+-----------+--------+
| Pets |
| +----+------+-----------+ |
| | id | name | Leg count | |
| +----+------+-----------+ |
| | 1 | Rex | 4 | |
| +----+------+-----------+ |
| | 2 | Ka | 0 | |
| …Run Code Online (Sandbox Code Playgroud) 我有OS X 10.6(Snow Leopard),它已经加载了Rails 2.Rails
现在是版本3,我即将开发Rails 和 JRails(JRuby on Rails).
我不想弄乱东西,我该怎么办?如何升级到Rails 3?我应该使用RVM(Ruby版本管理器)吗?我应该通过Homebrew安装JRuby吗?
在我的脚本中,我有一个部分需要将本地路径名称更改为绝对路径(不进入它,对不起)
我在用
args+="-f "
args+="$(realpath "$relative-path") "
jruby -Ilib bin/trace.rb $args
Run Code Online (Sandbox Code Playgroud)
这适用于脚本中的内容,但是当我将此绝对文件路径传递给ruby时,它不知道该怎么做.我可以想办法通过字符串替换在我的本地方框上解决这个问题.sub(C:for cygpath/c),但是如果我要将我的脚本部署到一个未知的文件系统,我可能会遇到麻烦.它需要在cygwin上进行开发(我知道我必须在寡妇中开发)和unix盒子.
题:
这是一种方法,我可以使我的脚本总是通过一个可用的路径作为一个arg到ruby(jruby,但这不重要).
对单个解决方案的建议或者以不同方式处理cygwin和unix环境的建议都是受欢迎的.
我有一个rake任务在dev env中运行正常,但不是prod.
task :sample_test_quote => :environment do
QuoterTester.test
end
Run Code Online (Sandbox Code Playgroud)
QuoterTester是一个带有类方法测试的模型类.
在dev下运行任务工作正常,如下所示:
rake sample_test_quote
Run Code Online (Sandbox Code Playgroud)
而在刺激下,我得到了这个:
$ RAILS_ENV=production rake sample_test_quote --trace
** Invoke sample_test_quote (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute sample_test_quote
rake aborted!
uninitialized constant QuoterTester
org/jruby/RubyModule.java:2590:in `const_missing'
/Users/kimptoc/.rvm/gems/jruby-1.6.5@global/gems/rake-0.9.2.2/lib/rake/ext/module.rb:36:in `const_missing'
org/jruby/RubyMethod.java:133:in `call'
/Users/kimptoc/Documents/ruby/ecom/ecom1/lib/tasks/sample_test_quote.rake:3:in `(root)'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
/Users/kimptoc/.rvm/gems/jruby-1.6.5@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute'
org/jruby/RubyArray.java:1612:in `each'
/Users/kimptoc/.rvm/gems/jruby-1.6.5@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/kimptoc/.rvm/gems/jruby-1.6.5@global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
/Users/kimptoc/.rvm/rubies/jruby-1.6.5/lib/ruby/1.8/monitor.rb:191:in `mon_synchronize'
/Users/kimptoc/.rvm/gems/jruby-1.6.5@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/kimptoc/.rvm/gems/jruby-1.6.5@global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/kimptoc/.rvm/gems/jruby-1.6.5@global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/kimptoc/.rvm/gems/jruby-1.6.5@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
org/jruby/RubyArray.java:1612:in `each'
/Users/kimptoc/.rvm/gems/jruby-1.6.5@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
/Users/kimptoc/.rvm/gems/jruby-1.6.5@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/kimptoc/.rvm/gems/jruby-1.6.5@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/kimptoc/.rvm/gems/jruby-1.6.5@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `run'
/Users/kimptoc/.rvm/gems/jruby-1.6.5@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' …Run Code Online (Sandbox Code Playgroud) 不知道如何在Ruby/Rails中做到这一点,我能想出的就是gsub.这给了我一个未定义的方法.
我正在做的是通过jQuery $ .post将数据传递给jRuby.我的问题是,有些浏览器(大多数)正在将@转换为%40,并且转换为%2C,这对我的作品造成了冲击.所以我想抓住具体的东西,将它们转换成"解码"时的字面意思.
我知道这是一个新手问题,我几乎肯定答案必须在网上的某个地方.但正如我所说的那样,我不断提出建议使用正则表达式的页面(我想避免使用,而且我并不精通).或其他暗示"gsub"的人.
更改(:hour => 1)在rails控制台中正常工作
irb(main):004:0> dt = DateTime.now
=> Mon, 10 Dec 2012 15:52:01 -0800
irb(main):005:0> _.change(:hour => 1)
=> Mon, 10 Dec 2012 01:00:00 -0800
irb(main):006:0>
irb(main):007:0> dt.class
=> DateTime
irb(main):008:0>
Run Code Online (Sandbox Code Playgroud)
但是在irb中引发了"未定义的方法`改变'"
irb(main):008:0> require 'active_record'
=> true
irb(main):009:0> dt = DateTime.now
=> #<DateTime: 2012-12-10T15:55:14-08:00 (10611097185737/4320000,-1/3,2299161)>
irb(main):010:0> dt.class
=> DateTime
irb(main):011:0> dt.change(:hour => 1)
NoMethodError: undefined method `change' for #<DateTime:0x53e20a9a>
from (irb):11:in `evaluate'
from org/jruby/RubyKernel.java:1070:in `eval'
from org/jruby/RubyKernel.java:1395:in `loop'
from org/jruby/RubyKernel.java:1178:in `catch'
from org/jruby/RubyKernel.java:1178:in `catch'
from C:\PF\jruby-1.7.0.preview2\bin\irb:13:in `(root)'
irb(main):012:0>
Run Code Online (Sandbox Code Playgroud)
有什么建议如何使其工作?
提前致谢.
我安装了Hadoop并且测试正常,但无法找到任何关于n00b的说明
如何设置级联和cascading.jruby.在哪里放置级联Jars以及如何配置jading以正确构建ruby组件?
是否有人使用jenkins自动构建?
编辑:更多细节我正在尝试从https://github.com/etsy/cascading.jruby构建示例字计数作业
我安装了
安装蚂蚁
创建了wordcount示例wc.rb
运行jade将wc.rb编译为jar
jade wc.rb
我得到以下编译错误
Buildfile:build.xml不存在!构建失败RuntimeError:Ant检索失败(root)at/usr/bin/hjade:89
看看玉代码是有道理的,但这个示例用法中没有涉及到这一点?我在这里错过了什么?
我在config.threadsafe!启用了线程模式()的JRuby 1.7上将Puma与Rails3一起使用 。
现在,随着理论的发展:对于传入的多个客户请求,将使用新线程来服务用户,而不是每次都启动新的Rails流程。
如果要查找此新请求线程的ID,该怎么办?
multithreading ruby-on-rails jruby jrubyonrails ruby-on-rails-3
我在生产中使用以下配置
应用程序运行正常.当我尝试上传图像时抛出apache错误
/var/log/apache2/error.log
[error] [client xxxx.xx.xxx.xx] Premature end of script headers: xxxx , referer:
Run Code Online (Sandbox Code Playgroud)
mongoid-paperclip gem已用于上传文件.甚至,我已经尝试了这里描述的步骤,但无法解决它.
它的开发工作很好.但是在生产上遇到上述问题.
请帮帮我!提前致谢 :)