Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'rubygems'
require 'mongo'
USER = 'tiger'
PASS = 'censusTIGER2009'
db = Mongo::Connection.new('flame.mongohq.com', 27058).db('tiger-2009')
db.authenticate(USER, PASS)
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
<h1>Simple Search/Pagination Example</h1>
<%= will_paginate @users %>
<% @users.each do |user| %>
<div>
<%= user.name %> (<%= user.email %>)
</div>
<% end %>
<%= will_paginate @users %>
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 }
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::BaseController < ApplicationController
include AuthenticatedSystem
include SslRequirement
audit Affiliate, Category, Industry, Permission, Promotion
before_filter :login_required
before_filter :site_administrator?
class Story < ActiveRecord::Base
acts_as_solr :facets => [:notes],
:fields => [
:name, :title,
:content, :display_name, :intro
]
end
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'}
@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'}