Skip to content

Instantly share code, notes, and snippets.

@chadwpry
chadwpry / model
Created September 25, 2008 22:13
class Story < ActiveRecord::Base
# FULLTEXT INDEXING
is_indexed :fields => [
{:field => 'title', :sortable => true},
:content, :teaser, :category_id
],
:include => [
{:association_name => 'category', :field => 'name', :as => 'category_name'},
{:association_name => 'category', :field => 'parent_id'}
class Story < ActiveRecord::Base
# FULLTEXT INDEXING
is_indexed :fields => [
{:field => 'title', :sortable => true},
:content, :teaser, :category_id
],
:include => [
{:association_name => 'category', :field => 'name', :as => 'category_name'},
{:association_name => 'category', :field => 'parent_id'}
@search = Ultrasphinx::Search.new(:query => @query)
@search.run
@search.results
$ rake ultrasphinx:configure
$ rake ultrasphinx:index
$ rake ultrasphinx:daemon:start
class Story < ActiveRecord::Base
acts_as_solr :facets => [:notes],
:fields => [
:name, :title,
:content, :display_name, :intro
]
end
$ rake solr:start
@criteria = params[:criteria]
if @criteria.size > 1
@result = Page.multi_solr_search @criteria, :models => [Brand, Leader, Career, Release]
if @result.nil?
@result = "Sorry no results for your search."
end
else
@result = "Please refine your search using more specific keywords."
end
class Admin::BaseController < ApplicationController
include AuthenticatedSystem
include SslRequirement
audit Affiliate, Category, Industry, Permission, Promotion
before_filter :login_required
before_filter :site_administrator?
class User < ActiveRecord::Base
...
define_index do
indexes [:first_name, :last_name], :as => :name, :sortable => true
indexes :email, :sortable => true
has created_at, updated_at
end
class Admin::UsersController < Admin::BaseController
...
def search
@users = User.search params[:s]
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @users }