ブラウザをhttp://localhost:3000/searches
に向けると、次のエラーが発生します。
Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.
なんで?そして、どうすればこれを修正できますか?
以下の関連コード...
/config/routes.rb:
resources :searches, :only => [:index]
/app/controllers/searches_controller.rb:
class SearchesController < ApplicationController
respond_to :html
filter_access_to :all
def index
@term = params[:term]
@results = PgSearch.multisearch(@term) unless @term.blank?
redirect_to searches_path
end
end
/app/views/searches/index.html.haml:
.textbox
= render "shared/notice"
%h1 Advanced Search
= simple_form_for @searches do |f|
= f.input :term
= f.button :submit
- unless @results.blank?
- @results.each do |result|
%h3= result.searchable.header
%p= result.searchable.body
/config/authorization_rules.rb:
authorization do
role :admin do
has_permission_on [...snip... :searches], :to => [:index, :show, :new, :create, :edit, :update, :destroy, :print, :none, :audit]
end
end
/app/models/reference.rb:
class Reference < ActiveRecord::Base
has_paper_trail
include PgSearch
multisearchable :against => [:source_text, :citation]
attr_accessible :reference_ids, :question_ids
attr_accessible :url, :citation, :details, :veracity_id, :original, :source_text
has_many :footnotes
def header
self.citation
end
def body
self.details
end
end
/app/models/footnote.rb:
class Footnote < ActiveRecord::Base
has_paper_trail
include PgSearch
multisearchable :against => [:details]
attr_accessible :reference_id, :details, :page_range, :relevant
belongs_to :reference
def header
[self.reference.citation, " ", self.page_range].join
end
def body
self.details
end
end
/db/migrate/20130326110126_create_pg_search_documents.rb:
class CreatePgSearchDocuments < ActiveRecord::Migration
def self.up
say_with_time("Creating table for pg_search multisearch") do
create_table :pg_search_documents do |t|
t.text :content
t.belongs_to :searchable, :polymorphic => true
t.timestamps
end
end
end
def self.down
say_with_time("Dropping table for pg_search multisearch") do
drop_table :pg_search_documents
end
end
end
/db/migrate/20130326110723_rebuild_search_indexes.rb:
class RebuildSearchIndexes < ActiveRecord::Migration
def up
PgSearch::Multisearch.rebuild(Reference)
PgSearch::Multisearch.rebuild(Footnote)
end
def down
PgSearch::Reference.delete_all
PgSearch::Footnote.delete_all
end
end