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
# environment.rb | |
config.after_initialize do | |
Qusion.start | |
Workling::Remote.invoker = Workling::Remote::Invokers::EventmachineSubscriber | |
Workling::Remote.dispatcher = Workling::Remote::Runners::ClientRunner.new | |
Workling::Remote.dispatcher.client = Workling::Clients::AmqpClient.new | |
end | |
# I have an after_save in my location model which tries to use workling to geocode | |
# a location with this line |
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
SELECT id FROM "boards" WHERE ((("boards"."visible" = 't')) AND ("boards"."id" IN (323,429,597,361,534,360,407,404,232,383,535,584,395,410,583,394,363,527,210,183,362,598,595,523))) ORDER BY targeted_on_occupations DESC LIMIT 10 OFFSET 0 | |
=> 534, 584, 527, 429, 323, 523, 394, 583, 232, 595 | |
SELECT id FROM "boards" WHERE ((("boards"."visible" = 't')) AND ("boards"."id" IN (323,429,597,361,534,360,407,404,232,383,535,584,395,410,583,394,363,527,210,183,362,598,595,523))) ORDER BY targeted_on_occupations DESC LIMIT 10 OFFSET 20 | |
=> 597, 595 | |
SELECT boards.id FROM "boards" LEFT OUTER JOIN taggings boards_taggings ON boards_taggings.taggable_id = boards.id AND boards_taggings.taggable_type = E'Board' LEFT OUTER JOIN tags boards_tags ON boards_tags.id = boards_taggings.tag_id WHERE ((boards_taggings.context = E'occupations' AND boards_tags.name IN (E'Direct Marketing (CRM)')) OR (boards_taggings.context = E'occupations' AND boards_tags.name IN (E'Brand/Product Marketing')) OR (boards_taggings.context = E'occupatio |
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
module Pickle | |
class Config | |
def predicates | |
@predicates ||= Pickle::Adapter.model_classes.map do |k| | |
k.public_instance_methods.select{|m| m =~ /\?$/} + k.fields.map(&:first) | |
end.flatten.uniq | |
end | |
end | |
class Adapter |
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
module Pickle | |
class Config | |
def predicates | |
@predicates ||= Pickle::Adapter.model_classes.map do |k| | |
k.public_instance_methods.select{|m| m =~ /\?$/} + k.fields.map(&:first) | |
end.flatten.uniq | |
end | |
end | |
class Adapter |
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
module MultiParameterAttributes | |
def attributes=(attrs) | |
multi_parameter_attributes = [] | |
attrs.each do |name, value| | |
return if attrs.blank? | |
if name.to_s.include?("(") | |
multi_parameter_attributes << [ name, value ] | |
else | |
writer_method = "#{name}=" | |
if respond_to?(writer_method) |
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
Devise::ConfirmationsController.class_eval do | |
param_accessible user: [ :email ], only: [ :create ] | |
end | |
Devise::PasswordsController.class_eval do | |
param_accessible user: [ :email ], only: [ :create ] | |
param_accessible :reset_password_token, only: [ :edit ] | |
param_accessible user: [ |
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
#!/usr/bin/env bash | |
echo "Running: heroku pgbackups:capture --remote production" | |
heroku pgbackups:capture --remote production | |
echo "curl'ing the latest.dump" | |
curl -o latest.dump `heroku pgbackups:url --remote production` | |
echo "restoring the dump" | |
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U postgres -d project_name_development latest.dump |
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
# This is a little ember easyform hack to make errors display when the form is | |
# submitted | |
Ember.EasyForm.Input.reopen | |
errorsChanged: (-> | |
@set('hasFocusedOut', true) | |
@showValidationError() | |
) | |
didInsertElement: -> | |
@addObserver("context.errors.#{@property}.@each", @, 'errorsChanged') |
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
# strong_params version, with business logic tied to controller. | |
class Something | |
validates :name, :age, :miles_travelled, presence: true | |
validates :age, :miles_travelled, :coffee_consumed, :children_eaten, | |
numericality: { allow_blank: true } | |
end | |
class SomethingController < ApplicationController::Base | |
respond_to :html | |
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
# Here's my experimentation so far with DDD and hexagonal architecture from the past few weeks. | |
# Code all written straight into this gist so probably full of typos and bugs. | |
# App consists of controllers, use_cases, policies, responses, services, forms, repositories, adapters, errors. | |
# Everything can be unit tested and mocked using bogus (https://www.relishapp.com/bogus/bogus/v/0-1-5/docs) | |
# Controllers can be tested with Rack::Test to ensure they run authetication and call the correct use case. | |
# All business logic is isolated from the delivery mechanism (grape) so that the delivery mechanism could | |
# be switched out. | |
# It would be easy for example to switch to Torqubox and JRuby to take advantage of the massive | |
# 10000 req/s performance (http://www.madebymarket.com/blog/dev/ruby-web-benchmark-report.html) compared | |
# to the slowness of Grape. |
OlderNewer