cehoffman-acts_as_ferret 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README +68 -0
- data/bin/aaf_install +23 -0
- data/config/ferret_server.yml +24 -0
- data/doc/README.win32 +23 -0
- data/doc/demo/README +154 -0
- data/doc/demo/README_DEMO +23 -0
- data/doc/demo/Rakefile +10 -0
- data/doc/demo/app/controllers/admin/backend_controller.rb +14 -0
- data/doc/demo/app/controllers/admin_area_controller.rb +4 -0
- data/doc/demo/app/controllers/application.rb +5 -0
- data/doc/demo/app/controllers/contents_controller.rb +49 -0
- data/doc/demo/app/controllers/searches_controller.rb +8 -0
- data/doc/demo/app/helpers/admin/backend_helper.rb +2 -0
- data/doc/demo/app/helpers/application_helper.rb +3 -0
- data/doc/demo/app/helpers/content_helper.rb +2 -0
- data/doc/demo/app/helpers/search_helper.rb +2 -0
- data/doc/demo/app/models/comment.rb +48 -0
- data/doc/demo/app/models/content.rb +12 -0
- data/doc/demo/app/models/content_base.rb +28 -0
- data/doc/demo/app/models/search.rb +19 -0
- data/doc/demo/app/models/shared_index1.rb +3 -0
- data/doc/demo/app/models/shared_index2.rb +3 -0
- data/doc/demo/app/models/special_content.rb +3 -0
- data/doc/demo/app/models/stats.rb +20 -0
- data/doc/demo/app/views/admin/backend/search.rhtml +18 -0
- data/doc/demo/app/views/contents/_form.rhtml +10 -0
- data/doc/demo/app/views/contents/edit.rhtml +9 -0
- data/doc/demo/app/views/contents/index.rhtml +24 -0
- data/doc/demo/app/views/contents/new.rhtml +8 -0
- data/doc/demo/app/views/contents/show.rhtml +8 -0
- data/doc/demo/app/views/layouts/application.html.erb +17 -0
- data/doc/demo/app/views/searches/_content.html.erb +2 -0
- data/doc/demo/app/views/searches/search.html.erb +20 -0
- data/doc/demo/config/boot.rb +109 -0
- data/doc/demo/config/database.yml +38 -0
- data/doc/demo/config/environment.rb +69 -0
- data/doc/demo/config/environments/development.rb +16 -0
- data/doc/demo/config/environments/production.rb +19 -0
- data/doc/demo/config/environments/test.rb +21 -0
- data/doc/demo/config/ferret_server.yml +18 -0
- data/doc/demo/config/lighttpd.conf +40 -0
- data/doc/demo/config/routes.rb +9 -0
- data/doc/demo/db/development_structure.sql +15 -0
- data/doc/demo/db/migrate/001_initial_migration.rb +18 -0
- data/doc/demo/db/migrate/002_add_type_to_contents.rb +9 -0
- data/doc/demo/db/migrate/003_create_shared_index1s.rb +11 -0
- data/doc/demo/db/migrate/004_create_shared_index2s.rb +11 -0
- data/doc/demo/db/migrate/005_special_field.rb +9 -0
- data/doc/demo/db/migrate/006_create_stats.rb +15 -0
- data/doc/demo/db/schema.sql +18 -0
- data/doc/demo/doc/README_FOR_APP +2 -0
- data/doc/demo/doc/howto.txt +70 -0
- data/doc/demo/public/.htaccess +40 -0
- data/doc/demo/public/404.html +8 -0
- data/doc/demo/public/500.html +8 -0
- data/doc/demo/public/dispatch.cgi +10 -0
- data/doc/demo/public/dispatch.fcgi +24 -0
- data/doc/demo/public/dispatch.rb +10 -0
- data/doc/demo/public/favicon.ico +0 -0
- data/doc/demo/public/images/rails.png +0 -0
- data/doc/demo/public/index.html +277 -0
- data/doc/demo/public/robots.txt +1 -0
- data/doc/demo/public/stylesheets/scaffold.css +74 -0
- data/doc/demo/script/about +3 -0
- data/doc/demo/script/breakpointer +3 -0
- data/doc/demo/script/console +3 -0
- data/doc/demo/script/destroy +3 -0
- data/doc/demo/script/ferret_server +10 -0
- data/doc/demo/script/generate +3 -0
- data/doc/demo/script/performance/benchmarker +3 -0
- data/doc/demo/script/performance/profiler +3 -0
- data/doc/demo/script/plugin +3 -0
- data/doc/demo/script/process/inspector +3 -0
- data/doc/demo/script/process/reaper +3 -0
- data/doc/demo/script/process/spawner +3 -0
- data/doc/demo/script/process/spinner +3 -0
- data/doc/demo/script/runner +3 -0
- data/doc/demo/script/server +3 -0
- data/doc/demo/test/fixtures/comments.yml +12 -0
- data/doc/demo/test/fixtures/contents.yml +13 -0
- data/doc/demo/test/fixtures/remote_contents.yml +9 -0
- data/doc/demo/test/fixtures/shared_index1s.yml +7 -0
- data/doc/demo/test/fixtures/shared_index2s.yml +7 -0
- data/doc/demo/test/functional/admin/backend_controller_test.rb +35 -0
- data/doc/demo/test/functional/contents_controller_test.rb +81 -0
- data/doc/demo/test/functional/searches_controller_test.rb +71 -0
- data/doc/demo/test/smoke/drb_smoke_test.rb +321 -0
- data/doc/demo/test/smoke/process_stats.rb +21 -0
- data/doc/demo/test/test_helper.rb +30 -0
- data/doc/demo/test/unit/comment_test.rb +217 -0
- data/doc/demo/test/unit/content_test.rb +705 -0
- data/doc/demo/test/unit/ferret_result_test.rb +24 -0
- data/doc/demo/test/unit/multi_index_test.rb +329 -0
- data/doc/demo/test/unit/remote_index_test.rb +23 -0
- data/doc/demo/test/unit/shared_index1_test.rb +108 -0
- data/doc/demo/test/unit/shared_index2_test.rb +13 -0
- data/doc/demo/test/unit/sort_test.rb +21 -0
- data/doc/demo/test/unit/special_content_test.rb +25 -0
- data/doc/demo/vendor/plugins/will_paginate/LICENSE +18 -0
- data/doc/demo/vendor/plugins/will_paginate/README +108 -0
- data/doc/demo/vendor/plugins/will_paginate/Rakefile +23 -0
- data/doc/demo/vendor/plugins/will_paginate/init.rb +21 -0
- data/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/collection.rb +45 -0
- data/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb +44 -0
- data/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/finder.rb +159 -0
- data/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb +95 -0
- data/doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb +23 -0
- data/doc/demo/vendor/plugins/will_paginate/test/boot.rb +27 -0
- data/doc/demo/vendor/plugins/will_paginate/test/console +10 -0
- data/doc/demo/vendor/plugins/will_paginate/test/finder_test.rb +219 -0
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/admin.rb +3 -0
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/companies.yml +24 -0
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/company.rb +23 -0
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/developer.rb +11 -0
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/developers_projects.yml +13 -0
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/project.rb +4 -0
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/projects.yml +7 -0
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/replies.yml +20 -0
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/reply.rb +5 -0
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/schema.sql +44 -0
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/topic.rb +19 -0
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/topics.yml +30 -0
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/user.rb +2 -0
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/users.yml +35 -0
- data/doc/demo/vendor/plugins/will_paginate/test/helper.rb +42 -0
- data/doc/demo/vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb +64 -0
- data/doc/demo/vendor/plugins/will_paginate/test/lib/load_fixtures.rb +10 -0
- data/doc/demo/vendor/plugins/will_paginate/test/pagination_test.rb +136 -0
- data/doc/monit-example +22 -0
- data/init.rb +24 -0
- data/install.rb +18 -0
- data/lib/act_methods.rb +147 -0
- data/lib/acts_as_ferret.rb +584 -0
- data/lib/ar_mysql_auto_reconnect_patch.rb +41 -0
- data/lib/blank_slate.rb +53 -0
- data/lib/bulk_indexer.rb +38 -0
- data/lib/class_methods.rb +270 -0
- data/lib/ferret_extensions.rb +188 -0
- data/lib/ferret_find_methods.rb +141 -0
- data/lib/ferret_result.rb +53 -0
- data/lib/ferret_server.rb +238 -0
- data/lib/index.rb +99 -0
- data/lib/instance_methods.rb +171 -0
- data/lib/local_index.rb +205 -0
- data/lib/more_like_this.rb +217 -0
- data/lib/multi_index.rb +126 -0
- data/lib/rdig_adapter.rb +148 -0
- data/lib/remote_functions.rb +23 -0
- data/lib/remote_index.rb +54 -0
- data/lib/remote_multi_index.rb +20 -0
- data/lib/search_results.rb +50 -0
- data/lib/server_manager.rb +58 -0
- data/lib/unix_daemon.rb +64 -0
- data/lib/without_ar.rb +52 -0
- data/rakefile +141 -0
- data/recipes/aaf_recipes.rb +114 -0
- data/script/ferret_daemon +94 -0
- data/script/ferret_server +10 -0
- data/script/ferret_service +178 -0
- data/tasks/ferret.rake +22 -0
- metadata +258 -0
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2006 Kasper Weibel, Jens Kraemer
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
= acts_as_ferret
|
|
2
|
+
|
|
3
|
+
This ActiveRecord mixin adds full text search capabilities to any Rails model.
|
|
4
|
+
|
|
5
|
+
It is heavily based on the original acts_as_ferret plugin done by
|
|
6
|
+
Kasper Weibel and a modified version done by Thomas Lockney, which
|
|
7
|
+
both can be found on http://ferret.davebalmain.com/trac/wiki/FerretOnRails
|
|
8
|
+
|
|
9
|
+
== Project Homepage
|
|
10
|
+
|
|
11
|
+
http://rm.jkraemer.net/projects/show/aaf
|
|
12
|
+
|
|
13
|
+
== Installation
|
|
14
|
+
|
|
15
|
+
Aaf is available via git from rubyforge.org and github.com. Github also offers
|
|
16
|
+
tarball downloads, check out http://github.com/jkraemer/acts_as_ferret/tree/master .
|
|
17
|
+
|
|
18
|
+
=== Installation inside your Rails project via script/plugin
|
|
19
|
+
|
|
20
|
+
script/plugin install git://github.com/jkraemer/acts_as_ferret.git
|
|
21
|
+
|
|
22
|
+
The rubyforge repository is located at git://rubyforge.org/actsasferret.git
|
|
23
|
+
|
|
24
|
+
=== Old SVN repository
|
|
25
|
+
|
|
26
|
+
In november 2008 I stopped updating the svn repository that has been the main
|
|
27
|
+
repository for aaf for several years. In case you want to retrieve any of the
|
|
28
|
+
older versions of the plugin, it's still there at
|
|
29
|
+
|
|
30
|
+
svn://code.jkraemer.net/acts_as_ferret/
|
|
31
|
+
|
|
32
|
+
=== System-wide installation with Rubygems
|
|
33
|
+
|
|
34
|
+
<tt>sudo gem install acts_as_ferret</tt>
|
|
35
|
+
|
|
36
|
+
To use acts_as_ferret in your project, add the following line to your
|
|
37
|
+
project's config/environment.rb:
|
|
38
|
+
|
|
39
|
+
<tt>require 'acts_as_ferret'</tt>
|
|
40
|
+
|
|
41
|
+
Call the aaf_install script that came with the gem inside your project
|
|
42
|
+
directory to install the sample config file and the drb server start/stop
|
|
43
|
+
script.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
== Usage
|
|
47
|
+
|
|
48
|
+
include the following in your model class (specifiying the fields you want to get indexed):
|
|
49
|
+
|
|
50
|
+
<tt>acts_as_ferret :fields => [ :title, :description ]</tt>
|
|
51
|
+
|
|
52
|
+
now you can use ModelClass.find_with_ferret(query) to find instances of your model
|
|
53
|
+
whose indexed fields match a given query. All query terms are required by default,
|
|
54
|
+
but explicit OR queries are possible. This differs from the ferret default, but
|
|
55
|
+
imho is the more often needed/expected behaviour (more query terms result in
|
|
56
|
+
less results).
|
|
57
|
+
|
|
58
|
+
Please see ActsAsFerret::ActMethods#acts_as_ferret for more information.
|
|
59
|
+
|
|
60
|
+
== License
|
|
61
|
+
|
|
62
|
+
Released under the MIT license.
|
|
63
|
+
|
|
64
|
+
== Authors
|
|
65
|
+
|
|
66
|
+
* Kasper Weibel Nielsen-Refs (original author)
|
|
67
|
+
* Jens Kraemer <jk@jkraemer.net> (current maintainer)
|
|
68
|
+
|
data/bin/aaf_install
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# acts_as_ferret gem install script
|
|
2
|
+
# Use inside the root of your Rails project
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
|
|
5
|
+
@basedir = File.join(File.dirname(__FILE__), '..')
|
|
6
|
+
|
|
7
|
+
def install(dir, file, executable=false)
|
|
8
|
+
puts "Installing: #{file}"
|
|
9
|
+
target = File.join('.', dir, file)
|
|
10
|
+
if File.exists?(target)
|
|
11
|
+
puts "#{target} already exists, skipping"
|
|
12
|
+
else
|
|
13
|
+
FileUtils.cp File.join(@basedir, dir, file), target
|
|
14
|
+
FileUtils.chmod 0755, target if executable
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
install 'script', 'ferret_server', true
|
|
20
|
+
install 'config', 'ferret_server.yml'
|
|
21
|
+
|
|
22
|
+
puts IO.read(File.join(@basedir, 'README'))
|
|
23
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# configuration for the acts_as_ferret DRb server
|
|
2
|
+
# host: where to reach the DRb server (used by application processes to contact the server)
|
|
3
|
+
# port: which port the server should listen on
|
|
4
|
+
# socket: where the DRb server should create the socket (absolute path), this setting overrides host:port configuration
|
|
5
|
+
# pid_file: location of the server's pid file (relative to RAILS_ROOT)
|
|
6
|
+
# log_file: log file (default: RAILS_ROOT/log/ferret_server.log
|
|
7
|
+
# log_level: log level for the server's logger
|
|
8
|
+
production:
|
|
9
|
+
host: localhost
|
|
10
|
+
port: 9010
|
|
11
|
+
pid_file: log/ferret.pid
|
|
12
|
+
log_file: log/ferret_server.log
|
|
13
|
+
log_level: warn
|
|
14
|
+
|
|
15
|
+
# aaf won't try to use the DRb server in environments that are not
|
|
16
|
+
# configured here.
|
|
17
|
+
#development:
|
|
18
|
+
# host: localhost
|
|
19
|
+
# port: 9010
|
|
20
|
+
# pid_file: log/ferret.pid
|
|
21
|
+
#test:
|
|
22
|
+
# host: localhost
|
|
23
|
+
# port: 9009
|
|
24
|
+
# pid_file: log/ferret.pid
|
data/doc/README.win32
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Credits
|
|
2
|
+
=======
|
|
3
|
+
|
|
4
|
+
The Win32 service support scripts have been written by
|
|
5
|
+
Herryanto Siatono <herryanto@pluitsolutions.com>.
|
|
6
|
+
|
|
7
|
+
See his accompanying blog posting at
|
|
8
|
+
http://www.pluitsolutions.com/2007/07/30/acts-as-ferret-drbserver-win32-service/
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
Usage
|
|
12
|
+
=====
|
|
13
|
+
|
|
14
|
+
There are two scripts:
|
|
15
|
+
|
|
16
|
+
script/ferret_service is used to install/remove/start/stop the win32 service.
|
|
17
|
+
|
|
18
|
+
script/ferret_daemon is to be called by Win32 service to start/stop the
|
|
19
|
+
DRbServer.
|
|
20
|
+
|
|
21
|
+
Run 'ruby script/ferret_service -h' for more info.
|
|
22
|
+
|
|
23
|
+
|
data/doc/demo/README
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
== Welcome to Rails
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
Rails is a web-application and persistence framework that includes everything
|
|
5
|
+
needed to create database-backed web-applications according to the
|
|
6
|
+
Model-View-Control pattern of separation. This pattern splits the view (also
|
|
7
|
+
called the presentation) into "dumb" templates that are primarily responsible
|
|
8
|
+
for inserting pre-built data in between HTML tags. The model contains the
|
|
9
|
+
"smart" domain objects (such as Account, Product, Person, Post) that holds all
|
|
10
|
+
the business logic and knows how to persist themselves to a database. The
|
|
11
|
+
controller handles the incoming requests (such as Save New Account, Update
|
|
12
|
+
Product, Show Post) by manipulating the model and directing data to the view.
|
|
13
|
+
|
|
14
|
+
In Rails, the model is handled by what's called an object-relational mapping
|
|
15
|
+
layer entitled Active Record. This layer allows you to present the data from
|
|
16
|
+
database rows as objects and embellish these data objects with business logic
|
|
17
|
+
methods. You can read more about Active Record in
|
|
18
|
+
link:files/vendor/rails/activerecord/README.html.
|
|
19
|
+
|
|
20
|
+
The controller and view are handled by the Action Pack, which handles both
|
|
21
|
+
layers by its two parts: Action View and Action Controller. These two layers
|
|
22
|
+
are bundled in a single package due to their heavy interdependence. This is
|
|
23
|
+
unlike the relationship between the Active Record and Action Pack that is much
|
|
24
|
+
more separate. Each of these packages can be used independently outside of
|
|
25
|
+
Rails. You can read more about Action Pack in
|
|
26
|
+
link:files/vendor/rails/actionpack/README.html.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
== Getting started
|
|
30
|
+
|
|
31
|
+
1. Run the WEBrick servlet: <tt>ruby script/server</tt> (run with --help for options)
|
|
32
|
+
...or if you have lighttpd installed: <tt>ruby script/lighttpd</tt> (it's faster)
|
|
33
|
+
2. Go to http://localhost:3000/ and get "Congratulations, you've put Ruby on Rails!"
|
|
34
|
+
3. Follow the guidelines on the "Congratulations, you've put Ruby on Rails!" screen
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
== Example for Apache conf
|
|
38
|
+
|
|
39
|
+
<VirtualHost *:80>
|
|
40
|
+
ServerName rails
|
|
41
|
+
DocumentRoot /path/application/public/
|
|
42
|
+
ErrorLog /path/application/log/server.log
|
|
43
|
+
|
|
44
|
+
<Directory /path/application/public/>
|
|
45
|
+
Options ExecCGI FollowSymLinks
|
|
46
|
+
AllowOverride all
|
|
47
|
+
Allow from all
|
|
48
|
+
Order allow,deny
|
|
49
|
+
</Directory>
|
|
50
|
+
</VirtualHost>
|
|
51
|
+
|
|
52
|
+
NOTE: Be sure that CGIs can be executed in that directory as well. So ExecCGI
|
|
53
|
+
should be on and ".cgi" should respond. All requests from 127.0.0.1 go
|
|
54
|
+
through CGI, so no Apache restart is necessary for changes. All other requests
|
|
55
|
+
go through FCGI (or mod_ruby), which requires a restart to show changes.
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
== Debugging Rails
|
|
59
|
+
|
|
60
|
+
Have "tail -f" commands running on both the server.log, production.log, and
|
|
61
|
+
test.log files. Rails will automatically display debugging and runtime
|
|
62
|
+
information to these files. Debugging info will also be shown in the browser
|
|
63
|
+
on requests from 127.0.0.1.
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
== Breakpoints
|
|
67
|
+
|
|
68
|
+
Breakpoint support is available through the script/breakpointer client. This
|
|
69
|
+
means that you can break out of execution at any point in the code, investigate
|
|
70
|
+
and change the model, AND then resume execution! Example:
|
|
71
|
+
|
|
72
|
+
class WeblogController < ActionController::Base
|
|
73
|
+
def index
|
|
74
|
+
@posts = Post.find_all
|
|
75
|
+
breakpoint "Breaking out from the list"
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
So the controller will accept the action, run the first line, then present you
|
|
80
|
+
with a IRB prompt in the breakpointer window. Here you can do things like:
|
|
81
|
+
|
|
82
|
+
Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint'
|
|
83
|
+
|
|
84
|
+
>> @posts.inspect
|
|
85
|
+
=> "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
|
|
86
|
+
#<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
|
|
87
|
+
>> @posts.first.title = "hello from a breakpoint"
|
|
88
|
+
=> "hello from a breakpoint"
|
|
89
|
+
|
|
90
|
+
...and even better is that you can examine how your runtime objects actually work:
|
|
91
|
+
|
|
92
|
+
>> f = @posts.first
|
|
93
|
+
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
|
|
94
|
+
>> f.
|
|
95
|
+
Display all 152 possibilities? (y or n)
|
|
96
|
+
|
|
97
|
+
Finally, when you're ready to resume execution, you press CTRL-D
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
== Console
|
|
101
|
+
|
|
102
|
+
You can interact with the domain model by starting the console through script/console.
|
|
103
|
+
Here you'll have all parts of the application configured, just like it is when the
|
|
104
|
+
application is running. You can inspect domain models, change values, and save to the
|
|
105
|
+
database. Starting the script without arguments will launch it in the development environment.
|
|
106
|
+
Passing an argument will specify a different environment, like <tt>console production</tt>.
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
== Description of contents
|
|
110
|
+
|
|
111
|
+
app
|
|
112
|
+
Holds all the code that's specific to this particular application.
|
|
113
|
+
|
|
114
|
+
app/controllers
|
|
115
|
+
Holds controllers that should be named like weblog_controller.rb for
|
|
116
|
+
automated URL mapping. All controllers should descend from
|
|
117
|
+
ActionController::Base.
|
|
118
|
+
|
|
119
|
+
app/models
|
|
120
|
+
Holds models that should be named like post.rb.
|
|
121
|
+
Most models will descend from ActiveRecord::Base.
|
|
122
|
+
|
|
123
|
+
app/views
|
|
124
|
+
Holds the template files for the view that should be named like
|
|
125
|
+
weblog/index.rhtml for the WeblogController#index action. All views use eRuby
|
|
126
|
+
syntax. This directory can also be used to keep stylesheets, images, and so on
|
|
127
|
+
that can be symlinked to public.
|
|
128
|
+
|
|
129
|
+
app/helpers
|
|
130
|
+
Holds view helpers that should be named like weblog_helper.rb.
|
|
131
|
+
|
|
132
|
+
config
|
|
133
|
+
Configuration files for the Rails environment, the routing map, the database, and other dependencies.
|
|
134
|
+
|
|
135
|
+
components
|
|
136
|
+
Self-contained mini-applications that can bundle together controllers, models, and views.
|
|
137
|
+
|
|
138
|
+
lib
|
|
139
|
+
Application specific libraries. Basically, any kind of custom code that doesn't
|
|
140
|
+
belong under controllers, models, or helpers. This directory is in the load path.
|
|
141
|
+
|
|
142
|
+
public
|
|
143
|
+
The directory available for the web server. Contains subdirectories for images, stylesheets,
|
|
144
|
+
and javascripts. Also contains the dispatchers and the default HTML files.
|
|
145
|
+
|
|
146
|
+
script
|
|
147
|
+
Helper scripts for automation and generation.
|
|
148
|
+
|
|
149
|
+
test
|
|
150
|
+
Unit and functional tests along with fixtures.
|
|
151
|
+
|
|
152
|
+
vendor
|
|
153
|
+
External libraries that the application depends on. Also includes the plugins subdirectory.
|
|
154
|
+
This directory is in the load path.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Acts_as_Ferret demo project
|
|
2
|
+
===========================
|
|
3
|
+
|
|
4
|
+
This project is intended to run with edge rails which can
|
|
5
|
+
be installed with
|
|
6
|
+
|
|
7
|
+
rake rails:freeze:edge
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
You'll also need to set up a database for it.
|
|
11
|
+
SQL scripts for both SQLite and MySQL are provided in db/ .
|
|
12
|
+
|
|
13
|
+
Just set up one of these, and configure your db connection
|
|
14
|
+
in config/database.yml .
|
|
15
|
+
|
|
16
|
+
after that run
|
|
17
|
+
rake
|
|
18
|
+
to see the unit tests pass.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
Please feel free to post bugs/enhancements/patches at
|
|
22
|
+
http://projects.jkraemer.net/acts_as_ferret .
|
|
23
|
+
|
data/doc/demo/Rakefile
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
|
2
|
+
# for example lib/tasks/switchtower.rake, and they will automatically be available to Rake.
|
|
3
|
+
|
|
4
|
+
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
|
|
5
|
+
|
|
6
|
+
require 'rake'
|
|
7
|
+
require 'rake/testtask'
|
|
8
|
+
require 'rake/rdoctask'
|
|
9
|
+
|
|
10
|
+
require 'tasks/rails'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class Admin::BackendController < AdminAreaController
|
|
2
|
+
|
|
3
|
+
def search
|
|
4
|
+
@query = params[:query] || ''
|
|
5
|
+
unless @query.blank?
|
|
6
|
+
@results = Content.find_with_ferret @query
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def show
|
|
11
|
+
@content = Content.find(params[:id])
|
|
12
|
+
render :template => 'content/show'
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
class ContentsController < ApplicationController
|
|
2
|
+
before_filter :find_content, :only => [ :show, :edit, :update, :destroy ]
|
|
3
|
+
|
|
4
|
+
def index
|
|
5
|
+
@contents = Content.paginate :page => params[:page]
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def show
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def new
|
|
12
|
+
@content = Content.new
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def create
|
|
16
|
+
@content = Content.new(params[:content])
|
|
17
|
+
if @content.save
|
|
18
|
+
flash[:notice] = 'Content was successfully created.'
|
|
19
|
+
redirect_to contents_url
|
|
20
|
+
else
|
|
21
|
+
render :action => 'new'
|
|
22
|
+
end
|
|
23
|
+
logger.error "#############{@content.errors.full_messages}"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def edit
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def update
|
|
30
|
+
if @content.update_attributes(params[:content])
|
|
31
|
+
flash[:notice] = 'Content was successfully updated.'
|
|
32
|
+
redirect_to :action => 'show', :id => @content
|
|
33
|
+
else
|
|
34
|
+
render :action => 'edit'
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def destroy
|
|
39
|
+
@content.destroy
|
|
40
|
+
redirect_to :action => 'list'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
protected
|
|
44
|
+
|
|
45
|
+
def find_content
|
|
46
|
+
@content = Content.find params[:id]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|