To edit pages or tickets please login with username/password: aaf/aaf

Changeset 312

Show
Ignore:
Timestamp:
02/02/08 21:36:54 (8 months ago)
Author:
jk
Message:

blank_slate fix for Rails < 2.x; cap recipe

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plugin/acts_as_ferret/lib/acts_as_ferret.rb

    r307 r312  
    2525require 'ferret' 
    2626 
     27require 'blank_slate' 
    2728require 'bulk_indexer' 
    2829require 'ferret_extensions' 
  • trunk/plugin/acts_as_ferret/lib/ferret_result.rb

    r310 r312  
    1010  end 
    1111 
    12   class FerretResult < BlankSlate 
     12  class FerretResult < ActsAsFerret::BlankSlate 
    1313    include ResultAttributes 
    1414    attr_accessor :id 
  • trunk/plugin/acts_as_ferret/lib/search_results.rb

    r310 r312  
    33  # decorator that adds a total_hits accessor and will_paginate compatible  
    44  # paging support to search result arrays 
    5   class SearchResults < BlankSlate 
     5  class SearchResults < ActsAsFerret::BlankSlate 
    66    reveal :methods 
    77    attr_reader :current_page, :per_page, :total_hits 
  • trunk/plugin/acts_as_ferret/recipes/aaf_recipes.rb

    r309 r312  
    1414# into current/ when you deploy. 
    1515# 
    16 # In order to use the ferret:rebuild task, declare the models you intend to 
     16# In order to use the ferret:index:rebuild task, declare the models you intend to 
    1717# index in config/deploy.rb: 
    1818# 
     
    2626# 
    2727# The two methods may be combined if you have a shared index, and some models 
    28 # indexed separately. 
     28# indexed separately.  
     29
     30# Like to submit a patch to aaf? Automatically determining the models that use  
     31# acts_as_ferret so the declaration of these variables in deploy.rb isn't  
     32# necessary anymore would be really cool ;-) 
    2933 
    3034namespace :ferret do 
     
    4246  desc "Restart the Ferret DRb server" 
    4347  task :restart, :roles => :app do 
    44     run "cd #{current_path}; script/ferret_server -e #{rails_env} stop; sleep 1; script/ferret_server -e #{rails_env} start" 
     48    top.ferret.stop 
     49    sleep 1 
     50    top.ferret.start 
    4551  end 
    4652 
    47   desc "Rebuild the Ferret index" 
    48   task :rebuild, :roles => :app do 
    49     rake = fetch(:rake, 'rake') 
    50     single_index_models = fetch(:ferret_single_index_models, nil) 
    51     if single_index_models 
    52       run "cd #{current_path}; RAILS_ENV=#{rails_env} MODEL='#{ferret_single_index_models.join(' ')}' #{rake} ferret:rebuild" 
     53  namespace :index do 
     54 
     55    desc "Rebuild the Ferret index. See aaf_recipes.rb for instructions." 
     56    task :rebuild, :roles => :app do 
     57      rake = fetch(:rake, 'rake') 
     58      single_index_models = fetch(:ferret_single_index_models, nil) 
     59      if single_index_models 
     60        run "cd #{current_path}; RAILS_ENV=#{rails_env} MODEL='#{ferret_single_index_models.join(' ')}' #{rake} ferret:rebuild" 
     61      end 
     62      fetch(:ferret_models, []).each do |m| 
     63        run "cd #{current_path}; RAILS_ENV=#{rails_env} MODEL='#{m}' #{rake} ferret:rebuild" 
     64      end 
    5365    end 
    54     fetch(:ferret_models, []).each do |m| 
    55       run "cd #{current_path}; RAILS_ENV=#{rails_env} MODEL='#{m}' #{rake} ferret:rebuild" 
     66 
     67    desc "purges all indexes for the current environment" 
     68    task :purge, :roles => :app do 
     69      run "rm -fr #{shared_path}/index/#{rails_env}" 
    5670    end 
    57   end 
    5871 
    59   desc "symlinks index folder" 
    60   task :symlink_index, :roles => :app do 
    61     run "mkdir -p  #{shared_path}/index && rm -f #{current_path}/index && ln -s #{shared_path}/index #{current_path}/index" 
     72    desc "symlinks index folder" 
     73    task :symlink, :roles => :app do 
     74      run "mkdir -p  #{shared_path}/index && rm -rf #{release_path}/index && ln -s #{shared_path}/index #{release_path}/index" 
     75    end 
     76 
    6277  end 
    6378 
     
    6782after "deploy:start",   "ferret:start" 
    6883after "deploy:restart", "ferret:restart" 
    69 after "deploy:symlink", "ferret:symlink_index
     84after "deploy:symlink", "ferret:index:symlink
    7085 

To edit pages or tickets please login with username/password: aaf/aaf