AJAX Search在开发/生产中的功能不同

时间:2013-03-01 03:00:13

标签: javascript ruby-on-rails ajax ruby-on-rails-3 heroku

我在我的应用中添加了即时搜索功能。

它完全按照我的意愿在本地服务器上运行:

  • 在按键上缩小列表
  • 案例不可知
  • 允许重置(因此,如果我键入内容然后将其删除,则重置搜索并取消缩小)。它也允许回溯,所以如果我输入错误并删除输入错误的字母,搜索会相应地进行修复。

在制作中,这种行为非常奇怪。虽然它也进行按键搜索,但它有许多奇怪的问题。

  • 区分大小写(与开发不同) - 这不是我想要的。
  • 关于重置,它表现得很奇怪。如果我键入类似“instatn”的内容然后更正错误,则不会重做搜索。如果删除整个条目,它也不会重做搜索。然而,奇怪的是,
  • 如果我删除搜索字词然后键入单个字母,则会重置搜索。
  • 似乎没有正确搜索,期间。如果我键入“z”,尽管我正在搜索的项目都没有包含“z”,但它们都没有消失。另一方面,如果我打字,说“博客”,列表实际上将缩小到名称中包含该单词的两个项目。

知道这里发生了什么吗?为什么两者不同?我该如何解决?让我知道什么样的代码可能有助于解释。

我的代码:

archive.html.erb

<%= form_tag @post, :method => 'get', :id => "posts_search", class: "search_form squeeze form-inline" do %>
  <p>
    <%= text_field_tag :search, params[:search], 
    placeholder: "Search titles:", id: "search_field" %>
    <%= submit_tag "Search", name: nil, class: "btn squeeze search" %>
  </p>
  <div id="list"><%= render 'search' %></div>
<% end %>

_search.html.erb

<ul class="blog_links">
<% @posts.first(@link_num).each do |p| %>
    <li class="total_hover">
        <%= p.name %>
    </li>
<% end %>
</ul>

archive.js.erb

$("#list").html("<%= escape_javascript(render("search")) %>");

posts_controller.rb

  def archive
    @posts = Post.search(params[:search]).reverse

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @posts }
      format.js
    end
  end

 def search
    @posts = Post.search(params[:search]).reverse
    render json: { results: @posts }
 end

post.rb

  def self.search(search)
    if search
      where('name LIKE ?', "%#{search}%")
    else
      scoped
    end
  end

Javascript角/ posts.js.coffee

@search = ->
  $.get $('#posts_search').attr("action"), $("#posts_search").serialize(), null, "script"

$ ->
  $('#posts_search input').keypress -> search()

  $('#posts_search').submit (e) ->
    e.preventDefault()
    search()

的routes.rb

match '/search', to: 'posts#search'
match '/archive', to: 'posts#archive'

编辑为了提供一些线索,我在两个环境中执行相同的用户行为并发布博客。我要做的是:

  1. 加载包含搜索的页面。
  2. 输入“Blgo”
  3. 删除“go”并将其替换为“og”
  4. 删除所有内容并搜索“Insta”
  5. 开发日志

    Started GET "/archive" for 127.0.0.1 at 2013-02-28 23:20:52 -0800
    Processing by PostsController#archive as HTML
      [1m[35mPost Load (0.2ms)[0m  SELECT "posts".* FROM "posts" 
      [1m[36mUser Load (0.1ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m  [["id", 1]]
      Rendered posts/_search.html.erb (55.7ms)
      Rendered posts/archive.html.erb within layouts/application (57.0ms)
      Rendered layouts/_shim.html.erb (0.0ms)
      Rendered layouts/_header.html.erb (0.7ms)
    Completed 200 OK in 74ms (Views: 72.2ms | ActiveRecord: 0.3ms)
    
    # Cut out bootstrap loading etc for brevity
    
    Started GET "/archive?utf8=%E2%9C%93&search=&_=1362122453454" for 127.0.0.1 at 2013-02-28 23:20:54 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"", "_"=>"1362122453454"}
      [1m[35mPost Load (0.2ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%%')
      [1m[36mUser Load (0.1ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m  [["id", 1]]
      Rendered posts/_search.html.erb (13.2ms)
      Rendered posts/archive.js.erb (14.7ms)
    Completed 200 OK in 18ms (Views: 16.6ms | ActiveRecord: 0.3ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=b&_=1362122453455" for 127.0.0.1 at 2013-02-28 23:20:54 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"b", "_"=>"1362122453455"}
      [1m[35mPost Load (0.1ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%b%')
      [1m[36mUser Load (0.1ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m  [["id", 1]]
      Rendered posts/_search.html.erb (2.4ms)
      Rendered posts/archive.js.erb (3.7ms)
    Completed 200 OK in 7ms (Views: 5.6ms | ActiveRecord: 0.2ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=b&_=1362122453456" for 127.0.0.1 at 2013-02-28 23:20:54 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"b", "_"=>"1362122453456"}
      [1m[35mPost Load (0.2ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%b%')
      [1m[36mUser Load (0.1ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m  [["id", 1]]
      Rendered posts/_search.html.erb (2.2ms)
      Rendered posts/archive.js.erb (3.4ms)
    Completed 200 OK in 7ms (Views: 5.7ms | ActiveRecord: 0.3ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=bl&_=1362122453457" for 127.0.0.1 at 2013-02-28 23:20:54 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"bl", "_"=>"1362122453457"}
      [1m[35mPost Load (0.1ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%bl%')
      [1m[36mUser Load (0.1ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m  [["id", 1]]
      Rendered posts/_search.html.erb (2.0ms)
      Rendered posts/archive.js.erb (3.2ms)
    Completed 200 OK in 6ms (Views: 5.1ms | ActiveRecord: 0.2ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=bl&_=1362122453458" for 127.0.0.1 at 2013-02-28 23:20:55 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"bl", "_"=>"1362122453458"}
      [1m[35mPost Load (0.1ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%bl%')
      [1m[36mUser Load (0.1ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m  [["id", 1]]
      Rendered posts/_search.html.erb (1.9ms)
      Rendered posts/archive.js.erb (3.1ms)
    Completed 200 OK in 6ms (Views: 4.9ms | ActiveRecord: 0.2ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=blg&_=1362122453459" for 127.0.0.1 at 2013-02-28 23:20:55 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"blg", "_"=>"1362122453459"}
      [1m[35mPost Load (0.1ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%blg%')
      Rendered posts/_search.html.erb (0.0ms)
      Rendered posts/archive.js.erb (1.3ms)
    Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.1ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=blg&_=1362122453460" for 127.0.0.1 at 2013-02-28 23:20:55 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"blg", "_"=>"1362122453460"}
      [1m[36mPost Load (0.1ms)[0m  [1mSELECT "posts".* FROM "posts" WHERE (name LIKE '%blg%')[0m
      Rendered posts/_search.html.erb (0.0ms)
      Rendered posts/archive.js.erb (1.2ms)
    Completed 200 OK in 4ms (Views: 3.3ms | ActiveRecord: 0.1ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=blgo&_=1362122453461" for 127.0.0.1 at 2013-02-28 23:20:55 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"blgo", "_"=>"1362122453461"}
      [1m[35mPost Load (0.1ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%blgo%')
      Rendered posts/_search.html.erb (0.0ms)
      Rendered posts/archive.js.erb (1.3ms)
    Completed 200 OK in 5ms (Views: 3.9ms | ActiveRecord: 0.1ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=blg&_=1362122453462" for 127.0.0.1 at 2013-02-28 23:20:55 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"blg", "_"=>"1362122453462"}
      [1m[36mPost Load (0.1ms)[0m  [1mSELECT "posts".* FROM "posts" WHERE (name LIKE '%blg%')[0m
      Rendered posts/_search.html.erb (0.0ms)
      Rendered posts/archive.js.erb (1.2ms)
    Completed 200 OK in 4ms (Views: 3.2ms | ActiveRecord: 0.1ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=bl&_=1362122453463" for 127.0.0.1 at 2013-02-28 23:20:55 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"bl", "_"=>"1362122453463"}
      [1m[35mPost Load (0.2ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%bl%')
      [1m[36mUser Load (0.1ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m  [["id", 1]]
      Rendered posts/_search.html.erb (2.0ms)
      Rendered posts/archive.js.erb (3.2ms)
    Completed 200 OK in 6ms (Views: 5.1ms | ActiveRecord: 0.2ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=bl&_=1362122453464" for 127.0.0.1 at 2013-02-28 23:20:56 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"bl", "_"=>"1362122453464"}
      [1m[35mPost Load (0.1ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%bl%')
      [1m[36mUser Load (0.1ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m  [["id", 1]]
      Rendered posts/_search.html.erb (2.1ms)
      Rendered posts/archive.js.erb (3.4ms)
    Completed 200 OK in 7ms (Views: 5.3ms | ActiveRecord: 0.2ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=blo&_=1362122453465" for 127.0.0.1 at 2013-02-28 23:20:56 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"blo", "_"=>"1362122453465"}
      [1m[35mPost Load (0.2ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%blo%')
      [1m[36mUser Load (0.1ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m  [["id", 1]]
      Rendered posts/_search.html.erb (2.8ms)
      Rendered posts/archive.js.erb (5.0ms)
    Completed 200 OK in 9ms (Views: 7.9ms | ActiveRecord: 0.3ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=blog&_=1362122453466" for 127.0.0.1 at 2013-02-28 23:20:56 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"blog", "_"=>"1362122453466"}
      [1m[35mPost Load (0.2ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%blog%')
      [1m[36mUser Load (0.1ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m  [["id", 1]]
      Rendered posts/_search.html.erb (2.8ms)
      Rendered posts/archive.js.erb (4.1ms)
    Completed 200 OK in 7ms (Views: 6.0ms | ActiveRecord: 0.2ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=blog&_=1362122453467" for 127.0.0.1 at 2013-02-28 23:20:56 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"blog", "_"=>"1362122453467"}
      [1m[35mPost Load (0.2ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%blog%')
      [1m[36mUser Load (0.1ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m  [["id", 1]]
      Rendered posts/_search.html.erb (2.0ms)
      Rendered posts/archive.js.erb (3.2ms)
    Completed 200 OK in 7ms (Views: 5.3ms | ActiveRecord: 0.2ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=blo&_=1362122453468" for 127.0.0.1 at 2013-02-28 23:20:57 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"blo", "_"=>"1362122453468"}
      [1m[35mPost Load (0.2ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%blo%')
      [1m[36mUser Load (0.1ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m  [["id", 1]]
      Rendered posts/_search.html.erb (2.1ms)
      Rendered posts/archive.js.erb (3.3ms)
    Completed 200 OK in 6ms (Views: 5.2ms | ActiveRecord: 0.2ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=bl&_=1362122453469" for 127.0.0.1 at 2013-02-28 23:20:57 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"bl", "_"=>"1362122453469"}
      [1m[35mPost Load (0.1ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%bl%')
      [1m[36mUser Load (0.1ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m  [["id", 1]]
      Rendered posts/_search.html.erb (1.9ms)
      Rendered posts/archive.js.erb (3.1ms)
    Completed 200 OK in 6ms (Views: 5.0ms | ActiveRecord: 0.2ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=b&_=1362122453470" for 127.0.0.1 at 2013-02-28 23:20:57 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"b", "_"=>"1362122453470"}
      [1m[35mPost Load (0.2ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%b%')
      [1m[36mUser Load (0.1ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m  [["id", 1]]
      Rendered posts/_search.html.erb (2.0ms)
      Rendered posts/archive.js.erb (3.2ms)
    Completed 200 OK in 6ms (Views: 5.0ms | ActiveRecord: 0.2ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=&_=1362122453471" for 127.0.0.1 at 2013-02-28 23:20:58 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"", "_"=>"1362122453471"}
      [1m[35mPost Load (0.2ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%%')
      [1m[36mUser Load (0.2ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m  [["id", 1]]
      Rendered posts/_search.html.erb (17.9ms)
      Rendered posts/archive.js.erb (19.4ms)
    Completed 200 OK in 23ms (Views: 21.2ms | ActiveRecord: 0.4ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=&_=1362122453472" for 127.0.0.1 at 2013-02-28 23:20:58 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"", "_"=>"1362122453472"}
      [1m[35mPost Load (0.2ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%%')
      [1m[36mUser Load (0.1ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m  [["id", 1]]
      Rendered posts/_search.html.erb (12.2ms)
      Rendered posts/archive.js.erb (13.7ms)
    Completed 200 OK in 17ms (Views: 15.6ms | ActiveRecord: 0.3ms)
    
    
    Started GET "/archive?utf8=%E2%9C%93&search=I&_=1362122453473" for 127.0.0.1 at 2013-02-28 23:20:58 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"I", "_"=>"1362122453473"}
      [1m[35mPost Load (0.2ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%I%')
      [1m[36mUser Load (0.1ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m  [["id", 1]]
      Rendered posts/_search.html.erb (4.6ms)
      Rendered posts/archive.js.erb (5.8ms)
    Completed 200 OK in 9ms (Views: 7.7ms | ActiveRecord: 0.2ms)
    
    #... You get the picture. I went over character count. (!)
    
    Started GET "/archive?utf8=%E2%9C%93&search=Insta&_=1362122453481" for 127.0.0.1 at 2013-02-28 23:20:59 -0800
    Processing by PostsController#archive as JS
      Parameters: {"utf8"=>"✓", "search"=>"Insta", "_"=>"1362122453481"}
      [1m[35mPost Load (0.2ms)[0m  SELECT "posts".* FROM "posts" WHERE (name LIKE '%Insta%')
      [1m[36mUser Load (0.1ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m  [["id", 1]]
      Rendered posts/_search.html.erb (2.2ms)
      Rendered posts/archive.js.erb (3.5ms)
    Completed 200 OK in 7ms (Views: 5.5ms | ActiveRecord: 0.3ms)
    

    heroku日志

    013-03-01T07:23:21+00:00 app[web.1]: Started GET "/archive" for 69.181.104.85 at 2013-03-01 07:23:21 +0000
    2013-03-01T07:23:21+00:00 heroku[router]: at=info method=GET path=/archive host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=1ms service=43ms status=200 bytes=3343
    2013-03-01T07:23:21+00:00 app[web.1]: Processing by PostsController#archive as HTML
    2013-03-01T07:23:21+00:00 app[web.1]: Completed 200 OK in 20ms (Views: 5.2ms | ActiveRecord: 13.2ms)
    2013-03-01T07:23:21+00:00 app[web.1]:   Rendered posts/_search.html.erb (2.2ms)
    2013-03-01T07:23:21+00:00 app[web.1]:   Rendered layouts/_header.html.erb (0.5ms)
    2013-03-01T07:23:21+00:00 app[web.1]:   Rendered layouts/_shim.html.erb (0.0ms)
    2013-03-01T07:23:21+00:00 app[web.1]:   Rendered posts/archive.html.erb within layouts/application (2.8ms)
    
    2013-03-01T07:23:24+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=&_=1362122601827" for 69.181.104.85 at 2013-03-01 07:23:24 +0000
    2013-03-01T07:23:24+00:00 app[web.1]: Processing by PostsController#archive as JS
    2013-03-01T07:23:24+00:00 app[web.1]:   Rendered posts/_search.html.erb (2.5ms)
    2013-03-01T07:23:24+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "search"=>"", "_"=>"1362122601827"}
    2013-03-01T07:23:24+00:00 app[web.1]:   Rendered posts/archive.js.erb (3.0ms)
    2013-03-01T07:23:24+00:00 app[web.1]: Completed 200 OK in 12ms (Views: 3.6ms | ActiveRecord: 7.1ms)
    
    2013-03-01T07:23:24+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=b&_=1362122601828" for 69.181.104.85 at 2013-03-01 07:23:24 +0000
    2013-03-01T07:23:24+00:00 app[web.1]: Processing by PostsController#archive as JS
    2013-03-01T07:23:24+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "search"=>"b", "_"=>"1362122601828"}
    2013-03-01T07:23:24+00:00 app[web.1]:   Rendered posts/archive.js.erb (0.4ms)
    2013-03-01T07:23:24+00:00 app[web.1]:   Rendered posts/_search.html.erb (0.0ms)
    2013-03-01T07:23:24+00:00 app[web.1]: Completed 200 OK in 6ms (Views: 0.9ms | ActiveRecord: 3.7ms)
    2013-03-01T07:23:24+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=b&_=1362122601828 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=2ms service=53ms status=200 bytes=53
    2013-03-01T07:23:24+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=&_=1362122601827 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=2ms service=198ms status=200 bytes=703
    
    2013-03-01T07:23:24+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=bl&_=1362122601829" for 69.181.104.85 at 2013-03-01 07:23:24 +0000
    2013-03-01T07:23:24+00:00 app[web.1]: Processing by PostsController#archive as JS
    2013-03-01T07:23:24+00:00 app[web.1]:   Rendered posts/_search.html.erb (0.0ms)
    2013-03-01T07:23:24+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "search"=>"bl", "_"=>"1362122601829"}
    2013-03-01T07:23:24+00:00 app[web.1]: Completed 200 OK in 5ms (Views: 0.9ms | ActiveRecord: 2.9ms)
    2013-03-01T07:23:24+00:00 app[web.1]:   Rendered posts/archive.js.erb (0.4ms)
    2013-03-01T07:23:24+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=bl&_=1362122601829 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=1ms service=89ms status=200 bytes=53
    2013-03-01T07:23:24+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=blg&_=1362122601830 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=2ms service=20ms status=200 bytes=53
    2013-03-01T07:23:24+00:00 app[web.1]: Completed 200 OK in 4ms (Views: 0.8ms | ActiveRecord: 2.6ms)
    2013-03-01T07:23:24+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "search"=>"blg", "_"=>"1362122601830"}
    2013-03-01T07:23:24+00:00 app[web.1]:   Rendered posts/archive.js.erb (0.4ms)
    2013-03-01T07:23:24+00:00 app[web.1]:   Rendered posts/_search.html.erb (0.0ms)
    2013-03-01T07:23:24+00:00 app[web.1]: Processing by PostsController#archive as JS
    
    2013-03-01T07:23:24+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=blg&_=1362122601830" for 69.181.104.85 at 2013-03-01 07:23:24 +0000
    
    2013-03-01T07:23:27+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=bl&_=1362122601831" for 69.181.104.85 at 2013-03-01 07:23:27 +0000
    2013-03-01T07:23:28+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=bl&_=1362122601831 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=2ms service=26ms status=200 bytes=53
    2013-03-01T07:23:28+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "search"=>"bl", "_"=>"1362122601831"}
    2013-03-01T07:23:28+00:00 app[web.1]: Processing by PostsController#archive as JS
    2013-03-01T07:23:28+00:00 app[web.1]:   Rendered posts/_search.html.erb (0.0ms)
    2013-03-01T07:23:28+00:00 app[web.1]:   Rendered posts/archive.js.erb (0.3ms)
    2013-03-01T07:23:28+00:00 app[web.1]: Completed 200 OK in 5ms (Views: 0.9ms | ActiveRecord: 2.6ms)
    
    2013-03-01T07:23:28+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=blo&_=1362122601832" for 69.181.104.85 at 2013-03-01 07:23:28 +0000
    2013-03-01T07:23:28+00:00 app[web.1]: Processing by PostsController#archive as JS
    2013-03-01T07:23:28+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "search"=>"blo", "_"=>"1362122601832"}
    2013-03-01T07:23:28+00:00 app[web.1]: Completed 200 OK in 4ms (Views: 0.8ms | ActiveRecord: 2.6ms)
    2013-03-01T07:23:28+00:00 app[web.1]:   Rendered posts/_search.html.erb (0.0ms)
    2013-03-01T07:23:28+00:00 app[web.1]:   Rendered posts/archive.js.erb (0.3ms)
    2013-03-01T07:23:28+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=blo&_=1362122601832 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=2ms service=61ms status=200 bytes=53
    
    2013-03-01T07:23:30+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=&_=1362122601833" for 69.181.104.85 at 2013-03-01 07:23:30 +0000
    2013-03-01T07:23:30+00:00 app[web.1]: Processing by PostsController#archive as JS
    2013-03-01T07:23:30+00:00 app[web.1]:   Rendered posts/archive.js.erb (2.5ms)
    2013-03-01T07:23:30+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "search"=>"", "_"=>"1362122601833"}
    2013-03-01T07:23:30+00:00 app[web.1]: Completed 200 OK in 7ms (Views: 3.0ms | ActiveRecord: 3.3ms)
    2013-03-01T07:23:30+00:00 app[web.1]:   Rendered posts/_search.html.erb (2.1ms)
    2013-03-01T07:23:30+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=&_=1362122601833 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=1ms service=19ms status=200 bytes=703
    
    2013-03-01T07:23:32+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=I&_=1362122601834" for 69.181.104.85 at 2013-03-01 07:23:32 +0000
    2013-03-01T07:23:32+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=I&_=1362122601834 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=2ms service=20ms status=200 bytes=218
    2013-03-01T07:23:32+00:00 app[web.1]:   Rendered posts/archive.js.erb (1.0ms)
    2013-03-01T07:23:32+00:00 app[web.1]: Completed 200 OK in 6ms (Views: 2.2ms | ActiveRecord: 2.6ms)
    2013-03-01T07:23:32+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "search"=>"I", "_"=>"1362122601834"}
    2013-03-01T07:23:32+00:00 app[web.1]: Processing by PostsController#archive as JS
    2013-03-01T07:23:32+00:00 app[web.1]:   Rendered posts/_search.html.erb (0.7ms)
    
    2013-03-01T07:23:32+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=In&_=1362122601835" for 69.181.104.85 at 2013-03-01 07:23:32 +0000
    2013-03-01T07:23:32+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "search"=>"In", "_"=>"1362122601835"}
    2013-03-01T07:23:32+00:00 app[web.1]:   Rendered posts/_search.html.erb (0.7ms)
    2013-03-01T07:23:32+00:00 app[web.1]:   Rendered posts/archive.js.erb (1.1ms)
    2013-03-01T07:23:32+00:00 app[web.1]: Completed 200 OK in 5ms (Views: 1.5ms | ActiveRecord: 2.8ms)
    2013-03-01T07:23:32+00:00 app[web.1]: Processing by PostsController#archive as JS
    2013-03-01T07:23:32+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=In&_=1362122601835 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=2ms service=27ms status=200 bytes=218
    
    2013-03-01T07:23:32+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=Ins&_=1362122601836" for 69.181.104.85 at 2013-03-01 07:23:32 +0000
    2013-03-01T07:23:32+00:00 app[web.1]: Processing by PostsController#archive as JS
    2013-03-01T07:23:32+00:00 app[web.1]: Completed 200 OK in 5ms (Views: 1.4ms | ActiveRecord: 2.8ms)
    2013-03-01T07:23:32+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "search"=>"Ins", "_"=>"1362122601836"}
    2013-03-01T07:23:32+00:00 app[web.1]:   Rendered posts/_search.html.erb (0.7ms)
    2013-03-01T07:23:32+00:00 app[web.1]:   Rendered posts/archive.js.erb (1.0ms)
    
    2013-03-01T07:23:32+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=Inst&_=1362122601837" for 69.181.104.85 at 2013-03-01 07:23:32 +0000
    2013-03-01T07:23:32+00:00 app[web.1]: Processing by PostsController#archive as JS
    2013-03-01T07:23:32+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "search"=>"Inst", "_"=>"1362122601837"}
    2013-03-01T07:23:32+00:00 app[web.1]:   Rendered posts/_search.html.erb (0.8ms)
    2013-03-01T07:23:32+00:00 app[web.1]: Completed 200 OK in 6ms (Views: 1.6ms | ActiveRecord: 3.4ms)
    2013-03-01T07:23:32+00:00 app[web.1]:   Rendered posts/archive.js.erb (1.1ms)
    2013-03-01T07:23:32+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=Inst&_=1362122601837 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=2ms service=18ms status=200 bytes=218
    
    2013-03-01T07:23:33+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=Insta&_=1362122601838" for 69.181.104.85 at 2013-03-01 07:23:33 +0000
    2013-03-01T07:23:33+00:00 app[web.1]: Processing by PostsController#archive as JS
    2013-03-01T07:23:33+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "search"=>"Insta", "_"=>"1362122601838"}
    2013-03-01T07:23:33+00:00 app[web.1]: Completed 200 OK in 5ms (Views: 1.4ms | ActiveRecord: 2.9ms)
    2013-03-01T07:23:33+00:00 app[web.1]:   Rendered posts/archive.js.erb (1.0ms)
    2013-03-01T07:23:33+00:00 app[web.1]:   Rendered posts/_search.html.erb (0.7ms)
    2013-03-01T07:23:33+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=Insta&_=1362122601838 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=2ms service=15ms status=200 bytes=218
    

    同样,虽然开发搜索工作完美且我认为通常是预期的,但在生产中,上面发生的事情是:列表缩小,直到我在“blg”中键入g,此时有没有更多的清单项目。当我删除“go”并输入“og”时,列表没有重新展开以在标题中包含带有“blog”的项目。当我删除搜索框中的所有字母时,它也没有包含所有内容。

    仅当我输入“I”时才重置搜索,并且因为Instant实际上是列表中的一个术语,它缩小到名称包含“Insta”的一个项目。

    所以,很奇怪。有什么想法在这里?

1 个答案:

答案 0 :(得分:0)

这(分离)最终只是一个数据库问题。

我正在运行sqlite开发和postgresql生成,这两个对我的搜索方法的反应不同。当我将开发转换为pg时,搜索在两种环境中同样被破坏,我决定使用Thinking Sphinx而不是自制解决方案。

相关问题