This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Cookbook Name:: delayed_job | |
# Recipe:: default | |
# | |
if ['solo', 'app', 'app_master'].include?(node[:instance_role]) | |
# be sure to replace "app_name" with the name of your application. | |
run_for_app("maloca") do |app_name, data| | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# EngineYard AppCloud before_symlink to copy public files to S3 | |
# lives in $RAILS_ROOT/deploy/before_symlink.rb | |
# | |
# Only need to run once | |
on_app_master do | |
aws_bucket = "<BUCKET_NAME>" | |
aws_access_key = "<YOUR ACCESS ID>" | |
aws_secret_key = "<YOUR SECRET KEY>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'active_record' | |
ActiveRecord::Base.establish_connection YAML.load(File.open(File.join(Rails.root, "config", "database.yml")))[Rails.env] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LoadsPresenter | |
extend ActiveSupport::Memoizable | |
def loads; raise "Implement #loads in subclass"; end | |
memoize :loads | |
def each(&block) | |
loads.each(&block) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Business < ActiveRecord | |
searchable do | |
text :name # Will be stored as a field named name_text in Solr | |
text :location # Will be stored as a field named location_text in Solr | |
end | |
end | |
# Given data set | |
# ID Name Location | |
# 1 Boone Moving Service Raleigh, NC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Business < ActiveRecord | |
searchable do | |
text :name | |
text :location | |
end | |
def self.custom_search(query) | |
search do | |
adjust_solr_params do |p| | |
# We want to break out all of the terms | |
terms = query.split(/[^a-zA-Z0-9]+/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<fieldType name="untokenized" class="solr.TextField"> | |
<analyzer> | |
<tokenizer class="solr.KeywordTokenizerFactory"/> | |
<filter class="solr.LowerCaseFilterFactory"/> | |
</analyzer> | |
</fieldType> | |
<fields> | |
<!-- ... --> | |
<field name="business_name_untokenized" stored="false" type="text_auto" multiValued="false" indexed="true"/> | |
</fields> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Business < ActiveRecord | |
searchable do | |
text :name | |
text :location | |
end | |
def self.custom_search(query) | |
search do | |
adjust_solr_params do |p| | |
# We want to break out all of the terms | |
terms = query.split(/[^a-zA-Z0-9]+/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Article < ActiveRecord::Base | |
default_scope where(:published => true) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for f in `find . -name '*.erb'`; do | |
new_f=`dirname $f`/`basename $f | sed s/erb/haml/`; | |
html2haml $f > $new_f; | |
git rm $f; | |
done |
OlderNewer