watson-acts_as_ferret 0.4.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. data/LICENSE +20 -0
  2. data/README +104 -0
  3. data/acts_as_ferret.gemspec +58 -0
  4. data/bin/aaf_install +29 -0
  5. data/config/ferret_server.yml +24 -0
  6. data/doc/README.win32 +23 -0
  7. data/doc/demo/README +154 -0
  8. data/doc/demo/README_DEMO +23 -0
  9. data/doc/demo/Rakefile +10 -0
  10. data/doc/demo/app/controllers/admin/backend_controller.rb +14 -0
  11. data/doc/demo/app/controllers/admin_area_controller.rb +4 -0
  12. data/doc/demo/app/controllers/application.rb +5 -0
  13. data/doc/demo/app/controllers/contents_controller.rb +49 -0
  14. data/doc/demo/app/controllers/searches_controller.rb +8 -0
  15. data/doc/demo/app/helpers/admin/backend_helper.rb +2 -0
  16. data/doc/demo/app/helpers/application_helper.rb +3 -0
  17. data/doc/demo/app/helpers/content_helper.rb +2 -0
  18. data/doc/demo/app/helpers/search_helper.rb +2 -0
  19. data/doc/demo/app/models/comment.rb +48 -0
  20. data/doc/demo/app/models/content.rb +12 -0
  21. data/doc/demo/app/models/content_base.rb +28 -0
  22. data/doc/demo/app/models/search.rb +19 -0
  23. data/doc/demo/app/models/shared_index1.rb +3 -0
  24. data/doc/demo/app/models/shared_index2.rb +3 -0
  25. data/doc/demo/app/models/special_content.rb +3 -0
  26. data/doc/demo/app/models/stats.rb +20 -0
  27. data/doc/demo/app/views/admin/backend/search.rhtml +18 -0
  28. data/doc/demo/app/views/contents/_form.rhtml +10 -0
  29. data/doc/demo/app/views/contents/edit.rhtml +9 -0
  30. data/doc/demo/app/views/contents/index.rhtml +24 -0
  31. data/doc/demo/app/views/contents/new.rhtml +8 -0
  32. data/doc/demo/app/views/contents/show.rhtml +8 -0
  33. data/doc/demo/app/views/layouts/application.html.erb +17 -0
  34. data/doc/demo/app/views/searches/_content.html.erb +2 -0
  35. data/doc/demo/app/views/searches/search.html.erb +20 -0
  36. data/doc/demo/config/boot.rb +109 -0
  37. data/doc/demo/config/database.yml +38 -0
  38. data/doc/demo/config/environment.rb +69 -0
  39. data/doc/demo/config/environments/development.rb +16 -0
  40. data/doc/demo/config/environments/production.rb +19 -0
  41. data/doc/demo/config/environments/test.rb +21 -0
  42. data/doc/demo/config/ferret_server.yml +18 -0
  43. data/doc/demo/config/lighttpd.conf +40 -0
  44. data/doc/demo/config/routes.rb +9 -0
  45. data/doc/demo/db/development_structure.sql +15 -0
  46. data/doc/demo/db/migrate/001_initial_migration.rb +18 -0
  47. data/doc/demo/db/migrate/002_add_type_to_contents.rb +9 -0
  48. data/doc/demo/db/migrate/003_create_shared_index1s.rb +11 -0
  49. data/doc/demo/db/migrate/004_create_shared_index2s.rb +11 -0
  50. data/doc/demo/db/migrate/005_special_field.rb +9 -0
  51. data/doc/demo/db/migrate/006_create_stats.rb +15 -0
  52. data/doc/demo/db/schema.sql +18 -0
  53. data/doc/demo/db/schema.sqlite +14 -0
  54. data/doc/demo/doc/README_FOR_APP +2 -0
  55. data/doc/demo/doc/howto.txt +70 -0
  56. data/doc/demo/public/404.html +8 -0
  57. data/doc/demo/public/500.html +8 -0
  58. data/doc/demo/public/dispatch.cgi +10 -0
  59. data/doc/demo/public/dispatch.fcgi +24 -0
  60. data/doc/demo/public/dispatch.rb +10 -0
  61. data/doc/demo/public/favicon.ico +0 -0
  62. data/doc/demo/public/images/rails.png +0 -0
  63. data/doc/demo/public/index.html +277 -0
  64. data/doc/demo/public/robots.txt +1 -0
  65. data/doc/demo/public/stylesheets/scaffold.css +74 -0
  66. data/doc/demo/script/about +3 -0
  67. data/doc/demo/script/breakpointer +3 -0
  68. data/doc/demo/script/console +3 -0
  69. data/doc/demo/script/destroy +3 -0
  70. data/doc/demo/script/ferret_server +10 -0
  71. data/doc/demo/script/generate +3 -0
  72. data/doc/demo/script/performance/benchmarker +3 -0
  73. data/doc/demo/script/performance/profiler +3 -0
  74. data/doc/demo/script/plugin +3 -0
  75. data/doc/demo/script/process/inspector +3 -0
  76. data/doc/demo/script/process/reaper +3 -0
  77. data/doc/demo/script/process/spawner +3 -0
  78. data/doc/demo/script/process/spinner +3 -0
  79. data/doc/demo/script/runner +3 -0
  80. data/doc/demo/script/server +3 -0
  81. data/doc/demo/test/fixtures/comments.yml +12 -0
  82. data/doc/demo/test/fixtures/contents.yml +13 -0
  83. data/doc/demo/test/fixtures/remote_contents.yml +9 -0
  84. data/doc/demo/test/fixtures/shared_index1s.yml +7 -0
  85. data/doc/demo/test/fixtures/shared_index2s.yml +7 -0
  86. data/doc/demo/test/functional/admin/backend_controller_test.rb +35 -0
  87. data/doc/demo/test/functional/contents_controller_test.rb +81 -0
  88. data/doc/demo/test/functional/searches_controller_test.rb +71 -0
  89. data/doc/demo/test/smoke/drb_smoke_test.rb +321 -0
  90. data/doc/demo/test/smoke/process_stats.rb +21 -0
  91. data/doc/demo/test/test_helper.rb +30 -0
  92. data/doc/demo/test/unit/comment_test.rb +217 -0
  93. data/doc/demo/test/unit/content_test.rb +705 -0
  94. data/doc/demo/test/unit/ferret_result_test.rb +24 -0
  95. data/doc/demo/test/unit/multi_index_test.rb +329 -0
  96. data/doc/demo/test/unit/remote_index_test.rb +23 -0
  97. data/doc/demo/test/unit/shared_index1_test.rb +108 -0
  98. data/doc/demo/test/unit/shared_index2_test.rb +13 -0
  99. data/doc/demo/test/unit/sort_test.rb +21 -0
  100. data/doc/demo/test/unit/special_content_test.rb +25 -0
  101. data/doc/demo/vendor/plugins/will_paginate/LICENSE +18 -0
  102. data/doc/demo/vendor/plugins/will_paginate/README +108 -0
  103. data/doc/demo/vendor/plugins/will_paginate/Rakefile +23 -0
  104. data/doc/demo/vendor/plugins/will_paginate/init.rb +21 -0
  105. data/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/collection.rb +45 -0
  106. data/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb +44 -0
  107. data/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/finder.rb +159 -0
  108. data/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb +95 -0
  109. data/doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb +23 -0
  110. data/doc/demo/vendor/plugins/will_paginate/test/boot.rb +27 -0
  111. data/doc/demo/vendor/plugins/will_paginate/test/console +10 -0
  112. data/doc/demo/vendor/plugins/will_paginate/test/finder_test.rb +219 -0
  113. data/doc/demo/vendor/plugins/will_paginate/test/fixtures/admin.rb +3 -0
  114. data/doc/demo/vendor/plugins/will_paginate/test/fixtures/companies.yml +24 -0
  115. data/doc/demo/vendor/plugins/will_paginate/test/fixtures/company.rb +23 -0
  116. data/doc/demo/vendor/plugins/will_paginate/test/fixtures/developer.rb +11 -0
  117. data/doc/demo/vendor/plugins/will_paginate/test/fixtures/developers_projects.yml +13 -0
  118. data/doc/demo/vendor/plugins/will_paginate/test/fixtures/project.rb +4 -0
  119. data/doc/demo/vendor/plugins/will_paginate/test/fixtures/projects.yml +7 -0
  120. data/doc/demo/vendor/plugins/will_paginate/test/fixtures/replies.yml +20 -0
  121. data/doc/demo/vendor/plugins/will_paginate/test/fixtures/reply.rb +5 -0
  122. data/doc/demo/vendor/plugins/will_paginate/test/fixtures/schema.sql +44 -0
  123. data/doc/demo/vendor/plugins/will_paginate/test/fixtures/topic.rb +19 -0
  124. data/doc/demo/vendor/plugins/will_paginate/test/fixtures/topics.yml +30 -0
  125. data/doc/demo/vendor/plugins/will_paginate/test/fixtures/user.rb +2 -0
  126. data/doc/demo/vendor/plugins/will_paginate/test/fixtures/users.yml +35 -0
  127. data/doc/demo/vendor/plugins/will_paginate/test/helper.rb +42 -0
  128. data/doc/demo/vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb +64 -0
  129. data/doc/demo/vendor/plugins/will_paginate/test/lib/load_fixtures.rb +10 -0
  130. data/doc/demo/vendor/plugins/will_paginate/test/pagination_test.rb +136 -0
  131. data/doc/monit-example +22 -0
  132. data/init.rb +24 -0
  133. data/install.rb +18 -0
  134. data/lib/act_methods.rb +147 -0
  135. data/lib/acts_as_ferret.rb +593 -0
  136. data/lib/ar_mysql_auto_reconnect_patch.rb +41 -0
  137. data/lib/blank_slate.rb +54 -0
  138. data/lib/bulk_indexer.rb +56 -0
  139. data/lib/class_methods.rb +279 -0
  140. data/lib/ferret_extensions.rb +192 -0
  141. data/lib/ferret_find_methods.rb +142 -0
  142. data/lib/ferret_result.rb +58 -0
  143. data/lib/ferret_server.rb +238 -0
  144. data/lib/index.rb +99 -0
  145. data/lib/instance_methods.rb +172 -0
  146. data/lib/local_index.rb +202 -0
  147. data/lib/more_like_this.rb +217 -0
  148. data/lib/multi_index.rb +133 -0
  149. data/lib/rdig_adapter.rb +149 -0
  150. data/lib/remote_functions.rb +43 -0
  151. data/lib/remote_index.rb +54 -0
  152. data/lib/remote_multi_index.rb +20 -0
  153. data/lib/search_results.rb +50 -0
  154. data/lib/server_manager.rb +71 -0
  155. data/lib/unix_daemon.rb +86 -0
  156. data/lib/without_ar.rb +52 -0
  157. data/recipes/aaf_recipes.rb +116 -0
  158. data/script/ferret_daemon +94 -0
  159. data/script/ferret_server +12 -0
  160. data/script/ferret_service +178 -0
  161. data/tasks/ferret.rake +39 -0
  162. metadata +246 -0
@@ -0,0 +1,38 @@
1
+ # MySQL (default setup). Versions 4.1 and 5.0 are recommended.
2
+ #
3
+ # Get the fast C bindings:
4
+ # gem install mysql
5
+ # (on OS X: gem install mysql -- --include=/usr/local/lib)
6
+ # And be sure to use new-style password hashing:
7
+ # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
8
+ #
9
+ # mysql config
10
+ development:
11
+ adapter: mysql
12
+ database: aaf_dev
13
+ username: ferret
14
+ password: ferret
15
+
16
+ test:
17
+ adapter: mysql
18
+ database: aaf_test
19
+ username: ferret
20
+ password: ferret
21
+
22
+ # since this is a demo, we won't need this one
23
+ #production:
24
+ # adapter: mysql
25
+ # database: ferret_production
26
+ # username: root
27
+ # password:
28
+ # socket: /var/run/mysqld/mysqld.sock
29
+
30
+ # SQLITE
31
+ #development:
32
+ # adapter: sqlite3
33
+ # dbfile: db/dev.sqlite
34
+
35
+ #test:
36
+ # adapter: sqlite3
37
+ # dbfile: db/test.sqlite
38
+
@@ -0,0 +1,69 @@
1
+ # Be sure to restart your web server when you modify this file.
2
+
3
+ # Uncomment below to force Rails into production mode when
4
+ # you don't control web/app server and can't set it the proper way
5
+ # ENV['RAILS_ENV'] ||= 'production'
6
+
7
+ # Bootstrap the Rails environment, frameworks, and default configuration
8
+ require File.join(File.dirname(__FILE__), 'boot')
9
+
10
+ Rails::Initializer.run do |config|
11
+ # Settings in config/environments/* take precedence those specified here
12
+
13
+ config.action_controller.session = { :session_key => "_demo_session", :secret => "aaaaaaaaaaaaaaaabbbbbbbbbbbbbbccccccccccccccsome secret phrase" }
14
+
15
+ # Skip frameworks you're not going to use
16
+ # config.frameworks -= [ :action_web_service, :action_mailer ]
17
+
18
+ # Add additional load paths for your own custom dirs
19
+ # config.load_paths += %W( #{RAILS_ROOT}/extras )
20
+
21
+ # Force all environments to use the same logger level
22
+ # (by default production uses :info, the others :debug)
23
+ # config.log_level = :debug
24
+
25
+ # Use the database for sessions instead of the file system
26
+ # (create the session table with 'rake create_sessions_table')
27
+ # config.action_controller.session_store = :active_record_store
28
+
29
+ # Enable page/fragment caching by setting a file-based store
30
+ # (remember to create the caching directory and make it readable to the application)
31
+ # config.action_controller.fragment_cache_store = :file_store, "#{RAILS_ROOT}/cache"
32
+
33
+ # Activate observers that should always be running
34
+ # config.active_record.observers = :cacher, :garbage_collector
35
+
36
+ # Make Active Record use UTC-base instead of local time
37
+ # config.active_record.default_timezone = :utc
38
+
39
+ # Use Active Record's schema dumper instead of SQL when creating the test database
40
+ # (enables use of different database adapters for development and test environments)
41
+ # config.active_record.schema_format = :ruby
42
+
43
+ # See Rails::Configuration for more options
44
+ end
45
+
46
+ # Add new inflection rules using the following format
47
+ # (all these examples are active by default):
48
+ # Inflector.inflections do |inflect|
49
+ # inflect.plural /^(ox)$/i, '\1en'
50
+ # inflect.singular /^(ox)en/i, '\1'
51
+ # inflect.irregular 'person', 'people'
52
+ # inflect.uncountable %w( fish sheep )
53
+ # end
54
+
55
+ # Include your application configuration below
56
+
57
+ ActsAsFerret::remote = false if ENV['AAF_REMOTE'] != 'true'
58
+ ActsAsFerret::raise_drb_errors = ENV['RAISE_DRB_ERRORS'] == 'true'
59
+
60
+ # define the index shared by the SharedIndex1 and SharedIndex2 classes
61
+ ActsAsFerret::define_index 'shared', :remote => ENV['AAF_REMOTE'] == 'true',
62
+ :raise_drb_errors => ENV['RAISE_DRB_ERRORS'] == 'true',
63
+ :fields => {
64
+ :name => { :store => :yes }
65
+ },
66
+ :ferret => {
67
+ :default_field => [ :name ]
68
+ }
69
+
@@ -0,0 +1,16 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # In the development environment your application's code is reloaded on
4
+ # every request. This slows down response time but is perfect for development
5
+ # since you don't have to restart the webserver when you make code changes.
6
+ config.cache_classes = false
7
+
8
+ # Log error messages when you accidentally call methods on nil.
9
+ config.whiny_nils = true
10
+
11
+ # Show full error reports and disable caching
12
+ config.action_controller.consider_all_requests_local = true
13
+ config.action_controller.perform_caching = false
14
+
15
+ # Don't care if the mailer can't send
16
+ config.action_mailer.raise_delivery_errors = false
@@ -0,0 +1,19 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The production environment is meant for finished, "live" apps.
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Use a different logger for distributed setups
8
+ # config.logger = SyslogLogger.new
9
+
10
+
11
+ # Full error reports are disabled and caching is turned on
12
+ config.action_controller.consider_all_requests_local = false
13
+ config.action_controller.perform_caching = true
14
+
15
+ # Enable serving of images, stylesheets, and javascripts from an asset server
16
+ # config.action_controller.asset_host = "http://assets.example.com"
17
+
18
+ # Disable delivery errors if you bad email addresses should just be ignored
19
+ # config.action_mailer.raise_delivery_errors = false
@@ -0,0 +1,21 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+ config.cache_classes = true
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.action_controller.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Tell ActionMailer not to deliver emails to the real world.
17
+ # The :test delivery method accumulates sent emails in the
18
+ # ActionMailer::Base.deliveries array.
19
+ config.action_mailer.delivery_method = :test
20
+
21
+ #config.log_level = :info
@@ -0,0 +1,18 @@
1
+ production:
2
+ host: ferret.yourdomain.com
3
+ port: 9010
4
+ pid_file: log/ferret.pid
5
+ development:
6
+ host: localhost
7
+ port: 9010
8
+ pid_file: log/ferret.pid
9
+ log_file: log/ferret_server_dev.log
10
+ log_level: info
11
+ test:
12
+ socket: /tmp/ferret.sock
13
+ # host: localhost
14
+ # port: 9009
15
+ pid_file: log/ferret.pid
16
+ log_file: log/ferret_server_test.log
17
+ log_level: debug
18
+
@@ -0,0 +1,40 @@
1
+ # Default configuration file for the lighttpd web server
2
+ # Start using ./script/server lighttpd
3
+
4
+ server.port = 3001
5
+
6
+ server.modules = ( "mod_rewrite", "mod_accesslog", "mod_fastcgi" )
7
+ server.error-handler-404 = "/dispatch.fcgi"
8
+ server.document-root = CWD + "/public/"
9
+
10
+ server.errorlog = CWD + "/log/lighttpd.error.log"
11
+ accesslog.filename = CWD + "/log/lighttpd.access.log"
12
+
13
+ url.rewrite = ( "^/$" => "index.html", "^([^.]+)$" => "$1.html" )
14
+
15
+ # Change *-procs to 2 if you need to use Upload Progress or other tasks that
16
+ # *need* to execute a second request while the first is still pending.
17
+ fastcgi.server = ( ".fcgi" =>
18
+ ( "localhost" =>
19
+ (
20
+ "min-procs" => 1,
21
+ "max-procs" => 1,
22
+ "socket" => CWD + "/tmp/sockets/fcgi.socket",
23
+ "bin-path" => CWD + "/public/dispatch.fcgi",
24
+ "bin-environment" => ( "RAILS_ENV" => "development" )
25
+ )
26
+ )
27
+ )
28
+
29
+ mimetype.assign = (
30
+ ".css" => "text/css",
31
+ ".gif" => "image/gif",
32
+ ".htm" => "text/html",
33
+ ".html" => "text/html",
34
+ ".jpeg" => "image/jpeg",
35
+ ".jpg" => "image/jpeg",
36
+ ".js" => "text/javascript",
37
+ ".png" => "image/png",
38
+ ".swf" => "application/x-shockwave-flash",
39
+ ".txt" => "text/plain"
40
+ )
@@ -0,0 +1,9 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+
3
+ map.resources :contents
4
+ map.search 'search', :controller => 'searches', :action => 'search'
5
+
6
+
7
+ # Install the default route as the lowest priority.
8
+ map.connect ':controller/:action/:id'
9
+ end
@@ -0,0 +1,15 @@
1
+ CREATE TABLE `comments` (
2
+ `id` int(11) NOT NULL auto_increment,
3
+ `author` varchar(100) NOT NULL default '',
4
+ `content` text NOT NULL,
5
+ `content_id` int(11) default NULL,
6
+ PRIMARY KEY (`id`)
7
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8
+
9
+ CREATE TABLE `contents` (
10
+ `id` int(11) NOT NULL auto_increment,
11
+ `title` varchar(100) NOT NULL default '',
12
+ `description` text NOT NULL,
13
+ PRIMARY KEY (`id`)
14
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
15
+
@@ -0,0 +1,18 @@
1
+ class InitialMigration < ActiveRecord::Migration
2
+ def self.up
3
+ create_table "comments" do |t|
4
+ t.column "author", :string, :limit => 100
5
+ t.column "content", :text
6
+ t.column "content_id", :integer
7
+ end
8
+ create_table "contents" do |t|
9
+ t.column "title", :string, :limit => 100
10
+ t.column "description", :text
11
+ end
12
+ end
13
+
14
+ def self.down
15
+ drop_table "comments"
16
+ drop_table "contents"
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ class AddTypeToContents < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :contents, :type, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :contents, :type
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ class CreateSharedIndex1s < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :shared_index1s do |t|
4
+ t.column :name, :string
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :shared_index1s
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateSharedIndex2s < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :shared_index2s do |t|
4
+ t.column :name, :string
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :shared_index2s
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ class SpecialField < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :contents, :special, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :contents, :special
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ class CreateStats < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :stats do |t|
4
+ t.integer :process_id, :processing_time, :open_connections
5
+ t.string :kind, :info
6
+ t.datetime :created_at
7
+ end
8
+ add_index :stats, 'kind'
9
+ end
10
+
11
+ def self.down
12
+ # remove_index :stats, 'kind'
13
+ drop_table :stats
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ drop table if exists contents;
2
+ create table contents (
3
+ id int not null auto_increment,
4
+ type varchar(255) not null,
5
+ title varchar(100) not null,
6
+ description text not null,
7
+ special varchar(255) not null,
8
+ primary key (id)
9
+ ) TYPE=InnoDB DEFAULT CHARSET=utf8;
10
+
11
+ drop table if exists comments;
12
+ create table comments (
13
+ id int not null auto_increment,
14
+ author varchar(100) not null,
15
+ content text not null,
16
+ content_id int,
17
+ primary key (id)
18
+ ) TYPE=InnoDB DEFAULT CHARSET=utf8;
@@ -0,0 +1,14 @@
1
+ drop table contents;
2
+ create table contents (
3
+ id INTEGER PRIMARY KEY,
4
+ title varchar(100),
5
+ description text
6
+ );
7
+
8
+ drop table comments;
9
+ create table comments (
10
+ id INTEGER PRIMARY KEY,
11
+ author varchar(100),
12
+ content text,
13
+ content_id int
14
+ );
@@ -0,0 +1,2 @@
1
+ Use this README file to introduce your application and point to useful places in the API for learning more.
2
+ Run "rake appdoc" to generate API documentation for your models and controllers.
@@ -0,0 +1,70 @@
1
+ This is a very minimalistic example of using ferret
2
+ to do full text searches in Rails model data. Tested with
3
+ Ruby 1.8.3, Rails 1.0 and Ferret 0.3.2.
4
+
5
+ You can install the latter with
6
+ gem install ferret
7
+
8
+
9
+ The steps it took me to create this small demo project were:
10
+
11
+ Rails project setup
12
+ ===================
13
+ These steps are pretty common and have nothing to do with ferret.
14
+
15
+ Create rails project
16
+ rails ferret
17
+ cd ferret
18
+
19
+ Create databases (if you don't use unix and/or sudo, use 'mysql -u root -p')
20
+ sudo mysql
21
+
22
+ create database ferret_development;
23
+ create database ferret_test;
24
+ grant all on ferret_development.* to 'ferret'@'localhost' identified by 'ferret';
25
+ grant all on ferret_test.* to 'ferret'@'localhost' identified by 'ferret';
26
+
27
+ Create database schema
28
+ mysql -u ferret -pferret ferret_development < db/schema.sql
29
+
30
+ Edit config/database.yml (user names and passwords)
31
+
32
+ Create content controller and model
33
+ script/generate scaffold Content
34
+
35
+ Running rake at this point should yield no errors.
36
+ Otherwise check your database configuration.
37
+
38
+
39
+ Ferret integration
40
+ ==================
41
+ Put acs_as_ferret plugin into vendor/plugin
42
+
43
+ Add ferret to the content model class:
44
+ acts_as_ferret :fields => [ 'title', 'description' ]
45
+
46
+ Add unit tests for the find_by_contents method to content_test.rb.
47
+
48
+ running rake should succeed, and there should be an index in
49
+ RAILS_ROOT/index/test/Content.
50
+
51
+ Extend the ContentController with a search method and create the search view
52
+ Add unit tests for the search method to content_controller_test.rb
53
+ Run rake again to see the tests pass.
54
+ Remember that, as a good programmer, you would've written the tests first,
55
+ before implementing the feature ;-)
56
+
57
+
58
+ Try it out
59
+ ==========
60
+ Run the app with script/server and create some content objects. You should
61
+ see the index in RAILS_ROOT/index/development/Content.
62
+
63
+ Try searching at http://localhost:3000/content/search
64
+
65
+
66
+ Please contact me if you find any bugs/problems within this howto or
67
+ in the code.
68
+
69
+ Jens Kraemer <jk@jkraemer.net>
70
+ Feel free to use under the terms of the MIT license.