This file contains hidden or 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
| ActiveAdmin.register Order do | |
| # Export the current collection of items with filtering and sorting | |
| # List the current collection ids | |
| collection_action :export_txt do | |
| render :text => collection.map { |order| order.id }.join(', ') | |
| end | |
| # Add a button to index page to export current collection as txt |
This file contains hidden or 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 'factory_girl_rails' | |
| require 'rspec' | |
| require 'rspec-rails' | |
| require 'rspec/mocks/standalone' # => if factories need stubs (for remote services for example) | |
| include FactoryGirl::Syntax::Methods # make FG methods available at top level, so you can do `> create :user` | |
| def reload_factories! | |
| FactoryGirl.instance_variable_set(:@factories, nil) # => clear loaded factories/sequences | |
| # FactoryGirl.instance_variable_set(:@sequences, nil) |
This file contains hidden or 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 'childprocess' | |
| guard 'shell' do | |
| watch %r{^app/(.+)\.rb$} do |m| | |
| `killall rake` | |
| # Why this: | |
| # - spawn a child process to avoid locking Guard | |
| # - make sure that the child process has stdout and stdin otherwise it crashes | |
| # - bonus point: get REPL access in the simulator! |
This file contains hidden or 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
| REMOVE_WORDS_ARRAY = ["llc", "co", "corp", "inc"] | |
| businesses_array = [["the bakery", "10012"],["law office inc", "10014"]] | |
| businesses_hashes = [] | |
| businesses_array.each do |business| | |
| our_hash = {} | |
| our_hash['BusinessName'] = business[0].strip unless business[0].nil? | |
| our_hash['BusinessZipCode'] = business[1].strip unless business[1].nil? |
This file contains hidden or 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 yum update | |
| sudo yum install java-1.7.0-openjdk.i686 -y | |
| wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.9.tar.gz -O elasticsearch.tar.gz | |
| tar -xf elasticsearch.tar.gz | |
| rm elasticsearch.tar.gz | |
| mv elasticsearch-* elasticsearch | |
| sudo mv elasticsearch /usr/local/share |
This file contains hidden or 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 ActiveRecord::Base | |
| def self.inherited(klass) | |
| callbacks = [:before_validation, :before_save, :before_create, :before_update] | |
| callbacks.each do |callback| | |
| klass.send(callback) do | |
| return unless respond_to?(:updated_by) || updated_by.nil? | |
| self.updated_by = Thread.current[:current_user] | |
| end | |
| end |