草庐IT

attributed-no-source

全部标签

ruby-on-rails - 错误 : When assigning attributes, 您必须将散列作为参数传递

嗨,我刚开始使用ruby​​,我正在编写Controller和Controller规范,但我遇到了一些问题。文档.rbclassDocument文档Controller.rbclassAPI::DocumentsControllerdocuments_controller_spec.rbdescribe"POST'index'"dobefore{@attr=FactoryGirl.attributes_for(:document)}describe"failure"dodescribe"withmissingparameters"dobefore{@attr.each{|key,val

ruby - 我在 "gem list"中看到 gem 但有 "no such file to load"

我在Ubuntu10上sudoapt-getinstallruby1.9.1-full然后下载rubygem1.3.7的源码并安装sudorubysetup.rb然后,例如,安装sinatrasudogeminstallsinatra最后打开irb并输入require"rubygems"require"sinatra"得到错误LoadError:nosuchfiletoload--sinatrafrom(irb):2:in`require'from(irb):2from/usr/bin/irb:12:in`' 最佳答案 我正好遇到了

ruby - custom_require.rb :36:in `require' : no such file to load -- myapp(LoadError)

我收到上述错误,我所做的只是安装rvm并从您使用mac获得的默认ruby​​更新到ruby​​1.9.2。我所有的gem都出现在gem列表中,但我需要在某处指定路径吗?干杯,格伦诺。 最佳答案 检查你是否安装了gemsgemlist如果没有,照常安装geminstallwhatever或者如果你想要特定版本geminstallwhatever-v1.2.3或者如果你的项目中有bundler(即Rails),它只是bundleinstall如果您拥有所有的gem,那么这可能是一个本地文件,并且您可能来自Ruby版本$LOAD_PATH

ruby - 如何在 Ruby 中设置 TLS 上下文选项(如 OpenSSL::SSL::SSL_OP_NO_SSLv2)

在C中使用OpenSSL时,我们在上下文中设置选项以删除SSLv2和SSLv3等薄弱和受伤的协议(protocol)。来自ssl.h,这里是一些有用选项的位掩码:#defineSSL_OP_NO_SSLv20x01000000L#defineSSL_OP_NO_SSLv30x02000000L#defineSSL_OP_NO_TLSv10x04000000L#defineSSL_OP_NO_TLSv1_20x08000000L#defineSSL_OP_NO_TLSv1_10x10000000L但是,我在Ruby中设置它们时遇到了问题:ifuri.scheme=="https"http

ruby-on-rails - Rails,activerecord : self[:attribute] vs self. 属性

在Rails中访问事件记录列/属性时,使用self[:attribute]与self.attribute有什么区别?这会影响getter和setter吗? 最佳答案 它们都只是获取属性的方法-它们都只是getter。self.attribtue是一个更“传统”的getter,而self[:attribute]基本上只是[]方法。在使用两者之间切换不会产生任何影响。我建议只使用self.attribute方法,因为它在语法上更好。但是,当其他内容覆盖self.attribute方法时,使用self[:attribute]会派上用场。例

ruby-on-rails - Elasticsearch /轮胎 : How do I filter a boolean attribute?

我想过滤我类(class)的私有(private)bool值,以便它只显示非私有(private)但对我不起作用的资源。(我大大简化了代码)mappingdoindexes:private,type:"boolean"indexes:name,type:"string"endenddefself.search(params)tire.search(load:true,page:params[:page],per_page:20)doquery{stringparams[:query]}ifparams[:query].present?#SofarI'vetried...#filter:

ruby-on-rails - 尝试使用 accepts_nested_attributes_for 和 has_and_belongs_to_many 但未填充连接表

我正在学习RoR并尝试使用accepts_nested_attributes_for和has_and_belongs_to_many来提交传统上为两种形式的信息。我在一些网站上看到它们兼容,一些网站不兼容,还有一些网站不知道。作为引用,我使用的是Rails2.3.4。我尝试根据nestedmodels上的Ryan'sScraps教程对我的解决方案进行建模从我尝试调试的内容来看,我似乎有两个问题,但我不确定为什么。当我提交包含嵌套模型的表单时,只发布了部分嵌套模型信息。我只得到第一个字段,而不是用户可能选择的“n”个其他字段在发布的单个字段中,没有任何行插入到我为HABTM关系创建的连接

ruby-on-rails - "No such file or directory @ rb_sysopen"使用 OpenURI

我最近在使用OpenURI时遇到了问题。每个open方法都会导致以下错误:"Nosuchfileordirectory@rb_sysopen".我的代码如下所示:data=open("http://google.ca/")我在将gem'nokogiri'添加到我的Gemfile并运行bundleinstall后不久就注意到了这个错误,尽管我不知道是否或这不是导致问题的原因,并且此后删除了该条目,对问题没有任何积极影响。任何帮助将不胜感激。 最佳答案 尝试在你的代码前写上require'open-uri'。

ruby-on-rails - 运行 Rspec 时出现 "No such file to load"错误

MacOS10.4rspec(1.1.11,1.1.4,1.1.3,0.5.15)rspec-rails(1.1.11)rspec_generator(0.5.15)rails2.2.2ruby1.8.6(2007-03-13patchlevel0)[universal-darwin8.0]创建了一个新项目...$railsmyproject将rspec安装到项目中...$script/generaterspec生成资源...$script/generaterspec_scaffoldmyresourcename:stringdescription:text试图运行规范...$rake

ruby - 如何使 --no-ri --no-rdoc 成为 gem 安装的默认值?

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Howtomake--no-ri--no-rdocthedefaultforgeminstall?我从不使用ri或rdoc,它们的安装时间太长。有没有什么地方可以让我这样做的配置文件