Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Configuraçao para o Masochism
- module ThinkingSphinx
- class Source
- include ThinkingSphinx::Source::InternalProperties
- include ThinkingSphinx::Source::SQL
- ActiveReload::ConnectionProxy::setup! if Rails.env.production?
- def set_source_sql(source, offset, delta = false)
- source.sql_query = to_sql(:offset => offset, :delta => delta).gsub(/\n/, ' ')
- source.sql_query_range = to_sql_query_range(:delta => delta)
- source.sql_query_info = to_sql_query_info(offset)
- source.sql_query_pre += send(!delta ? :sql_query_pre_for_core : :sql_query_pre_for_delta)
- if @index.local_options[:group_concat_max_len]
- source.sql_query_pre << "SET SESSION group_concat_max_len = #{@index.local_options[:group_concat_max_len]}"
- end
- # A BASE DE DADOS ESTA USANDO LATIN1, E POR ISSO O SPHINX NAO CONSEGUIA INDEXAR COM UTF8
- # POR ISSO COMENTAMOS ESSA LINHA
- # source.sql_query_pre += [adapter.utf8_query_pre].compact if utf8?
- end
- end
- end
- ## Configuraçao para o Masochism
- # if Rails.env.production?
- ThinkingSphinx::Source.class_eval do
- # we have to overwrite this method because it tries to access
- # @model.connection.instance_variable_get(:@config)
- def set_source_database_settings(source)
- ActiveReload::ConnectionProxy::setup! if Rails.env.production?
- current_db_conf = @model.configurations[Rails.env]['master_database'] || @model.configurations[Rails.env]['database']
- config = current_db_conf.symbolize_keys
- source.sql_host = config[:host] || "localhost"
- source.sql_user = config[:username] || config[:user] || ""
- source.sql_pass = (config[:password].to_s || "").gsub('#', '\#')
- source.sql_db = config[:database]
- source.sql_port = config[:port]
- source.sql_sock = config[:socket]
- end
- end
Add Comment
Please, Sign In to add comment