草庐IT

How_to_increase_Heap_Size_for_JUn

全部标签

ruby-on-rails - rails - 在 link_to 上传递 id 参数

我正在尝试将当前页面的参数(id)传递到下一页,以便我可以创建依赖模型条目。即项目有标,标属于项目。所以在项目的显示页面上我添加了链接创建并执行url...."http://localhost:3000/bids/new.2"我有defnew@bid=Bid.new@project=Project.find(params[:id])end在出价Controller中,但我不断收到错误消息“无法找到没有ID的项目”???怎么回事,怎么传不上id? 最佳答案 如果您的出价不是项目的嵌套资源,那么您可以将project_id作为参数添加到

ruby-on-rails - rails 4 : Flash message persists for the next page view

我在布局中使用以下代码来显示两种类型的即显消息:它们都工作正常,但无论何时触发一个,它仍会出现一次额外的页面View。我没有使用任何缓存gem。为什么会这样?我该如何解决? 最佳答案 使用flash.now而不是flash.flash变量旨在在redirect之前使用,并且它会在一个请求的结果页面上持续存在。这意味着如果我们不redirect,而不是简单的render一个页面,flash消息将持续存在两个请求:它出现在呈现的页面上但仍在等待重定向(即第二个请求),因此如果您单击链接,消息将再次出现。为了避免这种奇怪的行为,在渲染而不

ruby - Psych to_yaml 选项的文档?

Ruby1.9.3默认使用Psych对于YAML。同时theruby-docdocumentationforit完全没有,我找到了一份外部文档,暗示支持indentation选项。这在测试中得到证实:irb(main):001:0>RUBY_VERSION#=>"1.9.3"irb(main):002:0>require'yaml'#=>trueirb(main):003:0>[[[1]]].to_yaml#=>"---\n---1\n"irb(main):009:0>[[[1]]].to_yamlindentation:9#=>"---\n---1\n"大概有更多的支持选项。具体来说

ruby-on-rails - 如何从现有的 Time.zone for Rails 创建 Ruby DateTime?

我有用户在RubyonRails网站中输入日期。我将日期解析为DateTime对象,内容如下:date=DateTime.new(params[:year].to_i,params[:month].to_i,params[:day].to_i,params[:hour].to_i,params[:minute].to_i)或date=DateTime.parse(params[:date])两个DateTime都将不在我之前设置的用户时区中,例如:Time.zone="PacificTime(US&Canada)"如何将上述DateTime解析为正确的时区?我知道DateTime.ne

ruby-on-rails - 安装调试器时出错 : Failed to build gem native extension with ruby-1. 9.3-p362

尝试为新项目运行bundle时,遇到以下错误:Installingdebugger(1.2.2)withnativeextensionsGem::Installer::ExtensionBuildError:ERROR:Failedtobuildgemnativeextension.C:/Ruby193/bin/ruby.exeextconf.rbcheckingforrb_method_entry_t.called_idinmethod.h...nocheckingforrb_control_frame_t.method_idinmethod.h...nocheckingforrb_

ruby-on-rails - 如果为零,Rails 3.1 : Ruby idiom to prevent . 每个都从抛出异常?

有没有一种方法可以使用.each以便在对象为nil或空时不会抛出错误(无需添加额外的nil/空白测试?似乎如果我说phonelist.eachdo|phone|如果phonelist为空,则不应执行该block。但在我看来(haml)我有-@myvar.phonelist.eachdo|phone|如果电话列表为空,它会抛出一个NoMethodError。我经常遇到这个问题,并且总是通过为.blank添加显式检查/分支来解决这个问题?但似乎应该有一种更简单的方法来告诉.each空意味着什么都不做。 最佳答案 您可以使用try在nil

ruby - RSpec NoMethodError : "undefined method ` describe' for main Object"

我正在尝试学习Rspec。我在eclipse中的ruby项目如下-代码-require'rspec'require'./RubyOffRailsTuts/classes/furlong'describeFurlongdoend错误-/RubyOffRailsTuts/specs/furlong_spec.rb:6:in`':undefinedmethod`describe'formain:Object(NoMethodError)没有在网上得到任何有用的答案。我该如何解决这个问题? 最佳答案 作为RSpec.describe的前缀d

ruby-on-rails - Rails 3 安装错误 : "invalid value for @cert_chain"

我正在尝试在一台新的OSXSnowLeopard机器(安装了开发工具)上安装Rails3,当我sudogeminstallrails时,我收到以下错误:ERROR:Whileexecutinggem...(Gem::FormatException)builder-2.1.2hasaninvalidvaluefor@cert_chain更新失败。有没有人见过这个?我grep为“cert_chain”编辑了builder-2.1.2目录,但找不到任何线索。Ruby版本是1.8.7OSX10.6.6谢谢! 最佳答案 这是Rubygems1

ruby - rspec 失败错误 : expected false to respond to `false?`

我正在运行这部分测试:describeDictionarydobeforedo@d=Dictionary.newendit'cancheckwhetheragivenkeywordexists'do@d.include?('fish').shouldbe_falseend使用这段代码:classDictionarydefinitialize@hash={}enddefadd(new_entry)new_entry.class==String?@hash[new_entry]=nil:new_entry.each{|noun,definition|@hash[noun]=definiti

ruby-on-rails - ruby rails : provide vs content_for

我今天遇到了View辅助函数“provide”。通过查看它的手册,我仍然对它与“content_for”的不同之处感到困惑。provide(name,content=nil,&block)Thesameascontent_forbutwhenusedwithstreamingflushesstraightbacktothelayout.Inotherwords,ifyouwanttoconcatenateseveraltimestothesamebufferwhenrenderingagiventemplate,youshouldusecontent_for,ifnot,useprov