我最近在我的未来生产实例上安装了Rollbar,我发现Rollbar已经开始报告此问题,因为没有找到WordPress登录.
ActionController::RoutingError: No route matches [GET] "/blog/wp-login.php"
Run Code Online (Sandbox Code Playgroud)
我搜索了所有代码并且没有找到任何引用wp-login.php,堆栈跟踪也没有帮助.你知道这可能来自哪里吗?
"/home/myproject/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.13/lib/action_dispatch/middleware/debug_exceptions.rb" line 21 in call
"/home/myproject/shared/bundle/ruby/2.1.0/gems/rollbar-2.7.1/lib/rollbar/middleware/rails/show_exceptions.rb" line 22 in call_with_rollbar
"/home/myproject/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.13/lib/action_dispatch/middleware/show_exceptions.rb" line 30 in call
"/home/myproject/shared/bundle/ruby/2.1.0/gems/railties-4.0.13/lib/rails/rack/logger.rb" line 38 in call_app
"/home/myproject/shared/bundle/ruby/2.1.0/gems/railties-4.0.13/lib/rails/rack/logger.rb" line 20 in block in call
"/home/myproject/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.13/lib/active_support/tagged_logging.rb" line 68 in block in tagged
"/home/myproject/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.13/lib/active_support/tagged_logging.rb" line 26 in tagged
"/home/myproject/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.13/lib/active_support/tagged_logging.rb" line 68 in tagged
"/home/myproject/shared/bundle/ruby/2.1.0/gems/railties-4.0.13/lib/rails/rack/logger.rb" line 20 in call
"/home/myproject/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.13/lib/action_dispatch/middleware/request_id.rb" line 21 in call
"/home/myproject/shared/bundle/ruby/2.1.0/gems/rack-1.5.5/lib/rack/methodoverride.rb" line 21 in call
"/home/myproject/shared/bundle/ruby/2.1.0/gems/rack-1.5.5/lib/rack/runtime.rb" line 17 in call
"/home/myproject/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.13/lib/action_dispatch/middleware/static.rb" line 84 in call
"/home/myproject/shared/bundle/ruby/2.1.0/gems/rack-1.5.5/lib/rack/send.rb" line 112 …Run Code Online (Sandbox Code Playgroud) 我想使用find_by_sql方法代替活动记录查询接口,因为我在编写自己的SQL时具有灵活性.
例如,
在SQL中,将查询中的表从最小到最大排序,这被认为是一种很好的做法.使用活动记录查询界面时,您必须从可能是最大表的结果模型开始.
我还可以通过在连接本身中包含目标表并包含多个表中所需的列来轻松避免N + 1问题.
我想知道是否有理由我不应该使用find_by_sql选项,特别是当我将编写ANSI SQL时,它应该与所有(如果不是大多数)数据库兼容.
谢谢!
在JavaScript回调函数中,我在页面上显示成功/失败消息.当我将HTML内容放在一行中时,就像下面的代码一样,消息被添加,一切正常!
$('#message').html("<div class='alert alert-danger'><i class='fa fa-times-circle fa-2x'>Incorrect!</div>")
Run Code Online (Sandbox Code Playgroud)
但是当我尝试格式化HTML以获得更好的可读性时,如下所示 - 没有任何反应,我在Firebug控制台中看不到我要添加的消息或任何错误消息.
$('#message').html("<div class='alert alert-danger'>
<p><i class='fa fa-times-circle fa-2x'>
Incorrect! Yesterday was " + <%= @yesterday %> +
"</p>
<p>Click Next to continue.</p>
</div>")
Run Code Online (Sandbox Code Playgroud)
我不确定是什么问题,任何帮助表示赞赏!
我有一个包含哈希的数组,如下所示.我试图加入这些哈希的文本部分,这是我最好的.
array_hashes = [{"seq"=>0, "text"=>"got"},
{"type"=>"ignore", "seq"=>1, "text"=>"to"},
{"seq"=>2, "text"=>"go"}]
a = Array.new
array_hashes.each {|h| a << h["text"]}
a.join("-")
=> got-to-go
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来写这个?
我有这样的哈希 -
{"examples"=>
[{"year"=>1999,
"provider"=>{"name"=>"abc", "id"=>711},
"url"=> "http://example.com/1",
"reference"=>"abc",
"text"=> "Sample text 1",
"title"=> "Sample Title 1",
"documentId"=>30091286,
"exampleId"=>786652043,
"rating"=>357.08115},
{"year"=>1999,
"provider"=>{"name"=>"abc", "id"=>3243},
"url"=> "http://example.com/2",
"reference"=>"dec",
"text"=> "Sample text 2",
"title"=> "Sample Title 2",
"documentId"=>30091286,
"exampleId"=>786652043,
"rating"=>357.08115},
{"year"=>1999,
"provider"=>{"name"=>"abc", "id"=>191920},
"url"=> "http://example.com/3",
"reference"=>"wer",
"text"=> "Sample text 3",
"title"=> "Sample Title 3",
"documentId"=>30091286,
"exampleId"=>786652043,
"rating"=>357.08115}]
}
Run Code Online (Sandbox Code Playgroud)
并且我想通过拉出键来创建一个新数组,并且仅为"text","url"和"title"键提供值,如下所示.
[
{"text"=> "Sample text 1", "title"=> "Sample Title 1", "url"=> "http://example.com/1"},
{"text"=> "Sample text 2", "title"=> "Sample Title 2", "url"=> "http://example.com/2"},
{"text"=> "Sample text …Run Code Online (Sandbox Code Playgroud) 我有一个像这样的文本字符串,我需要删除所有回车符和反斜杠。
一头牛来到芦苇丛旁喝水。当他重重地跳进水里时,他把一只小青蛙压进了泥里。\r\n\r\n老青蛙很快就想念小青蛙了,并问他的兄弟姐妹他怎么样了。\r\n\r \n\n\“一个巨大的怪物,”其中一个说道,“用一只巨大的脚踩到了弟弟!”\r\n\r\n“他很大!”老青蛙,趾高气扬。\“他有这么大吗?”\r\n\r\n\“哦,大得多!”他们喊道。\r\n\r\n青蛙更加膨胀了。\r\n\ r\n“他不可能比这更大了,”她说。但小青蛙们都说这个怪物要大得多,而老青蛙则不断地把自己吹得越来越大,直到突然爆裂。\r\n
我尝试了这个,但这仍然遗漏了反斜杠。
text.gsub(/\r?\n|\r/, "")
Run Code Online (Sandbox Code Playgroud)
“一头牛来到芦苇丛旁喝水。当他重重地跳进水里时,他把一只小青蛙压进了泥里。老青蛙很快就想念小青蛙了,就问他的兄弟姐妹他怎么样了。” “一个巨大的怪物,”其中一个说,“用一只巨大的脚踩到了弟弟!”“他很大!”老青蛙骄傲地说道。“他是吗? ” “有这么大吗?怪物越来越大,老青蛙不断地把自己吹得越来越大,直到突然爆裂。”
以下表达式似乎与www.rubular.com上的正确模式匹配,包括各个反斜杠,但似乎在我的控制台中不起作用(Ruby 2.2.1)
text.gsub(/(\\r\\n)|\\/, "")
Run Code Online (Sandbox Code Playgroud)
注意:为了充分披露,该文本字符串在 HTML 编辑器中捕获并存储到数据库列中。我需要去掉 HTML 字符,我使用以下内容 -
text = ActionView::Base.full_sanitizer.sanitize(page.content).gsub(/\r?\n|\r\\|\\/, "")
Run Code Online (Sandbox Code Playgroud)
我感谢您提供的任何帮助!