草庐IT

On_PushButton

全部标签

ruby-on-rails - 参数错误 : Factory not registered

我正在尝试使用FactoryGirl运行rspec,但我一直收到此错误:1)ProductsUpdatewithinvalidinformationFailure/Error:let(:product){FactoryGirl.create(:product)}ArgumentError:Factorynotregistered:product#./spec/requests/products_spec.rb:47:in`block(3levels)in'#./spec/requests/products_spec.rb:52:in`block(3levels)in'-这是有错误的测试

ruby-on-rails - 允许用户使用 Devise - Rails 4 更改密码

我正在设置最后一点设计,需要允许用户从他们的“我的帐户”页面更改他们的密码。我看过这个https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-edit-their-password)页面,但仍无法使其正常工作。当我点击链接调出我的模态时,出现以下错误。ActionController::RoutingError(Noroutematches[GET]"/users/1/change_password_modal"):当我提交更改密码请求时,出现以下错误:unknownattribute:current_pa

ruby-on-rails - ElasticSearch Rails - 设置自定义分析器

我通过elasticsearch-rails(https://github.com/elasticsearch/elasticsearch-rails)在Rails4中使用ElasticSearch我有一个带有电子邮件属性的用户模型。我正在尝试使用文档中描述的“uax_url_email”分词器:classUser我按照wiki(https://github.com/elasticsearch/elasticsearch-rails/wiki)和elasticsearch-model文档(https://github.com/elasticsearch/elasticsearch-ra

ruby-on-rails - 如何记录某个 url 的整个请求( header 、正文等)?

我需要将所有请求(包括HTTPheader、正文等)记录到某个url。我试过这段代码:defindexglobal_request_loggingendprivatedefglobal_request_logginghttp_request_header_keys=request.headers.keys.select{|header_name|header_name.match("^HTTP.*")}http_request_headers=request.headers.select{|header_name,header_value|http_request_header_key

ruby-on-rails - 安装/bundle gem unf_ext -v '0.0.6' 时出错

我正在尝试bundleintallunf_ext-v'0.0.6'但我一直收到此错误:Gem::Ext::BuildError:ERROR:Failedtobuildgemnativeextension.checkingformain()in-lstdc++...yescheckingforruby/encoding.h...yescreatingMakefilemake"DESTDIR="cleanmake"DESTDIR="compilingunf.ccInfileincludedfromunf.cc:1:Infileincludedfrom./unf/normalizer.hh:

ruby-on-rails - 如何以一种 rails 形式处理多个模型?

我有以下型号classSurvey我的Controller:defnew@survey=Survey.newsurvey_section=@survey.survey_sections.buildsurvey_section.questions.buildenddefcreate@survey=Survey.new(survey_params)if@survey.saveredirect_to@survey,notice:'Super'elserender'new'endenddefsurvey_paramsparams.require(:survey).permit(:title,:

ruby-on-rails - Ruby on Rails 不兼容库

我刚刚开始了解ruby​​onrails,但无法让服务器运行。我正在运行ruby​​2.3.0和rails4.2.5,在我有一个新的rail项目后,我尝试运行bin/railsserver但出现以下错误:Warning:Running`gempristine--all`toregenerateyourinstalledgemspecs(anddeletingthenreinstallingyourbundleifyouusebundle--path)willimprovethestartupperformanceofSpring./Users/John/.rvm/gems/ruby-h

ruby-on-rails - 自定义 RESTful 资源的 url_for(复合键;不仅仅是 id)

给定以下资源定义:map.resources:posts,:except=>[:show]map.post'/:year/:month/:slug,:controller=>:posts,:action=>:show我可以让url_for为我工作,使用这个语法:'2010',:month=>'02',:slug=>'test')%>但是有没有办法让它工作呢?目前它抛出这个错误:Noroutematches{:year=>#,:controller=>"posts",:action=>"show"}显然它将@post对象传递给第一个路由参数(看起来像一个Rails错误...)。但是我可以

ruby-on-rails - like-vim emacs ruby​​ 缩进

来自svn的ruby​​-mode,看起来等于1.1版本这里是哈希的emacs缩进User.all({:joins=>:account,:conditions=>{:delete_at=>nil}})在vim中也是一样User.all({:joins=>:account,:conditions=>{:delete_at=>nil}})如何在ruby​​模式下使emacs像vim一样缩进? 最佳答案 尝试M-x自定义模式;您将看到用于自定义Ruby缩进的选项。看起来您可能想将“RubyDeepIndentParen”更改为nil。

ruby-on-rails - 如何使用 Test::Unit 跳过某些测试

在我的一个项目中,我需要与多个后端系统协作。其中一些缺少文档,部分原因是我有一些测试代码与一些测试服务器交互,只是为了查看一切都按预期工作。但是,访问这些服务器非常慢,因此我不想在每次运行测试套件时都运行这些测试。我的问题是如何处理您想跳过某些测试的情况。目前我使用一个环境变量“BACKEND_TEST”和一个条件语句来检查是否为我想跳过的每个测试设置了变量。但有时我想跳过测试文件中的所有测试,而不必在每个测试的开头添加额外的行。需要与测试服务器交互的测试并不多,因为我在其他情况下使用flexmock。但是,您不能mock自己远离现实。从这个问题的标题可以看出,我使用的是Test::U