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
cd ~ | |
sudo apt-get update | |
sudo apt-get install openjdk-7-jre-headless -y | |
# Download the compiled elasticsearch rather than the source. | |
wget http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.20.2.tar.gz -O elasticsearch.tar.gz | |
tar -xf elasticsearch.tar.gz | |
rm elasticsearch.tar.gz | |
sudo mv elasticsearch-* elasticsearch | |
sudo mv elasticsearch /usr/local/share |
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
# Run with: rake environment elasticsearch:reindex | |
# Begins by creating the index using tire:import:model command. This will create the "official" index name, e.g. "things" each time. | |
# Then we rename it to, e.g. "things_20121001052916" and alias "things" to it. | |
namespace :elasticsearch do | |
desc "re-index elasticsearch" | |
task :reindex => :environment do | |
klasses = [ | |
User, |
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
SimpleForm.setup do |config| | |
config.wrappers :bootstrap, :tag => 'div', :class => 'form-group', :error_class => 'error' do |b| | |
b.use :html5 | |
b.use :placeholder | |
b.use :label | |
b.wrapper :tag => 'div', :class=> 'col-lg-10' do |ba| | |
ba.use :input # , :class => ['form-control'] | |
ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' } | |
ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
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
I was having trouble setting the default_url for paperclip attachables while using rails 4 asset pipeline fingerprints. | |
What was not working for some reason: | |
default_url: ActionController::Base.helpers.asset_path('event_default.jpg') | |
What worked for me: | |
default_url: lambda { |image| ActionController::Base.helpers.asset_path('event_default.jpg') } |
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 using elasticsearch in specs. This (hopefully) solves the issue of brittle tests | |
# from elasaticsearch's refresh interval of 1 second. | |
# -1 for instant refresh: | |
# => http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules.html | |
# 30 merge factor for faster index creation: | |
# => http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-merge.html | |
RestClient.put "#{ENV['ELASTICSEARCH_URL']}/_settings ", %<{ | |
"index" : { | |
"refresh_interval" : "-1", | |
"merge.policy.merge_factor" : 30 |
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
# I was getting this error randomly in my specs: | |
# Circular dependency detected while autoloading constant UsersController | |
# the fix for me was changing the following mistake: | |
school = FactoryGirl.create(:school) | |
# to be | |
let(:school) { FactoryGirl.create(:school) } |
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
Rails expects an array of ids but because select2 uses a hidden input for multiple-ajax configuration, it returned a comma separated string. To get around this I did a check and conversion at the beginning of my strong params function: | |
if params[:interview_schedule] and params[:interview_schedule][:contact_ids] and params[:interview_schedule][:contact_ids][0].include?(",") | |
params[:interview_schedule][:contact_ids] = params[:interview_schedule][:contact_ids][0].split(",") | |
end | |
Thanks to https://coderwall.com/p/cxrwsw# for the motivation. |
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
# These are all the cops that are enabled in the default configuration. | |
Style/AccessModifierIndentation: | |
Description: Check indentation of private/protected visibility modifiers. | |
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#indent-public-private-protected' | |
Enabled: false | |
Style/AccessorMethodName: | |
Description: Check the naming of accessor methods for get_/set_. | |
Enabled: true |
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
def self.search(params) | |
params[:query] = params[:query].downcase if params[:query].present? # Only finds if downcased | |
tire.search(load: params[:load] || false, page: params[:page], per_page: params[:per_page] || 25) do | |
query do | |
boolean minimum_number_should_match: 1 do | |
Searchable.should_match_multi_field(self, params, 'name', 10) | |
Searchable.should_fuzzy_match(self, params, :name) | |
end if params[:query].present? | |
boolean do |
OlderNewer