草庐IT

match、term

全部标签

ruby-on-rails - 更新方法 "No route matches [POST]"

在使用以下ruby​​onrails代码片段时遇到了一些麻烦-我有书并且想更新书名,这是我尝试这样做的方法:Editthebook""Name这就是我在booksController中所做的:defedit@book=Book.find(params[:id])enddefupdate@book=Book.find(params[:id])if@book.update_attributes(params[:book])redirect_to:action=>'show',id=>@bookelse@subjects=Subject.find(:all)render:action=>'e

ruby - ActiveRecord - 未定义的方法 'match'

我试图在我的记录中编码一个简单的层次结构,但我遇到了一个奇怪的错误。require'rubygems'require'active_record'ActiveRecord::Base.establish_connection(:adapter=>"sqlite3",:database=>":memory:")ActiveRecord::Schema.definedocreate_table:foosdo|t|t.string:name,:null=>falset.integer:parent_id,:default=>nilendendclassFooFooendbar=Foo.cre

ruby 心印 : regex parentheses "capture" matched content?

我正在浏览about_regular_expressions.rb并且不明白这里到底发生了什么:deftest_variables_can_also_be_used_to_access_capturesassert_equal"Gray,James","Name:Gray,James"[/(\w+),(\w+)/]assert_equal"Gray",$1assert_equal"James",$2end在我看来,似乎在正则表达式中使用括号会在幕后创建两个新变量($1和$2)。这是正确的吗?但后来我这样做了:deftest_variables_can_also_be_used_to_a

ruby-on-rails - 错误 : SELECT DISTINCT ON expressions must match initial ORDER BY expressions

我的要求是得到不同的记录并按顺序User.joins('INNERJOINreport_postsONposts.id=report_posts.post_id').select('DISTINCTON(report_posts.post_id)posts.idasreport_posts.idasreported_id,report_posts.reported_at').order('report_posts.reported_atdesc')我知道这在postgresql中是不可能的,我已经读过这个PostgresqlDISTINCTONwithdifferentORDERBY我

如果在没有 shell 的情况下运行,Ruby 将以退出代码 1 响应 TERM 退出

如果Ruby接收到TERM信号,它通常以退出代码143退出,根据thissource表示进程已成功响应该信号。但是如果我让脚本在没有shell的情况下运行,退出代码是1。带外壳:>catDockerfileFROMruby:alpineCMDruby-e"Process.kill('TERM',Process.pid)"#dockerbuild-tterm_shell.>/dev/null>dockerrunterm_shellTerminated>echo$?143没有外壳:>catDockerfileFROMruby:alpineCMD["ruby","-e","Process.k

ruby-on-rails - Xpath 2.0 - xmlXPathCompOpEval : function matches not found

我在我的Rails项目中运行Xpath2.0,并尝试使用它提供的matches()函数,如下所示:page=Mechanize.new.get('http://www.example.com').parserpage.search("//a[matches(text(),'lagerfordon','i')]").first.text抛出以下错误:RuntimeError:xmlXPathCompOpEval:functionmatchesnotfound我做错了什么? 最佳答案 Nokogiri(Mechanize构建于其上)使用

ruby-on-rails - Rails_Admin 显示路由错误 "No route matches {:controller=>"home"}"

我按照说明安装了Rails_Admin,并且也在使用Devise。当我尝试导航到“/admin”时,出现以下错误:RoutingErrorNoroutematches{:controller=>"home"}这是我的routes.rb:Ot::Application.routes.drawdoresources:badgeshipsresources:badgesresources:profilesresources:universitiesresources:degreesresources:jobsresources:resourcesresources:communitiesre

ruby-on-rails - Rails devise 求助路由报错 No route matches "/sessions/user"

当我登录我的页面时,我会自动转到路线:http://localhost:3000/sessions/user我得到这个错误:RoutingErrorNoroutematches"/sessions/user"我在此处的用户文件夹中创建了一个名为sessions_controller.rb的Controller:classUsers::SessionsController"Youhavebeenloggedout."enddefcreateuser=User.authenticate(params[:login],params[:encrypted_password])ifuserses

ruby - Rails - 如何处理不存在的路由 ("No route matches [GET]")?

我的路线看起来像match'about'=>'company#about'当我设置为urlhttp://localhost:3000/aboutttt时,我收到错误消息Noroutematches[GET]"/aboutttt"我想给用户更好的反馈。我认为最好的解决方案是将应用程序重定向回来,或者在应用程序的主页上重定向,但在出现上述错误时以任何方式存在于路由中以设置默认路由? 最佳答案 当你在开发的时候。通过设置在config/environments/development.rb中进行更改:config.consider_all

ruby-on-rails - rails 4 : No route matches - issue with relationships missing id key

我希望有人能帮助我。我遇到以下问题:Noroutematches{:action=>"show",:controller=>"stocks",:stockpile_id=>#,:id=>nil,:format=>nil}missingrequiredkeys:[:id]访问以下URL时:/admin/stockpiles/3/stocks/我的路线是这样的:scope'/admin'doroot:to=>'admin#index',:as=>'admin'resources:stockpiles,:companiesscope:path=>'stockpiles/:stockpile_