Skip to content

Instantly share code, notes, and snippets.

@mattetti
Created August 15, 2010 06:47
Show Gist options
  • Save mattetti/525179 to your computer and use it in GitHub Desktop.
Save mattetti/525179 to your computer and use it in GitHub Desktop.
# Add that to your app make, after you define the sinatra env.
Thread.current[:thinking_sphinx_environment] = Sinatra::Application.environment
# When requiring TS add a new task to properly generate the config file
require 'thinking_sphinx'
require 'thinking_sphinx/tasks'
namespace :thinking_sphinx do
namespace :my_app do
desc "Generate the Sphinx configuration file using Thinking Sphinx's settings"
task :setup => :app_env do
Thread.current[:thinking_sphinx_environment] = Sinatra::Application.environment
config = ThinkingSphinx::Configuration.instance
config.reset(Sinatra::Application.root)
puts "Generating Configuration to #{config.config_file}"
config.build
end
end
end
@mattetti
Copy link
Author

The only think you really need to care about is:

Thread.current[:thinking_sphinx_environment] = Sinatra::Application.environment
ThinkingSphinx::Configuration.instance.reset(Sinatra::Application.root)

If you set that up in your main file before loading your ts tasks, you are good to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment