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
# MODEL | |
class Case < ActiveRecord::Base | |
include Eventable | |
has_many :tasks | |
concerning :Assignment do | |
def assign_to(new_owner:, details:) | |
transaction do |
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
# autoload concerns | |
module YourApp | |
class Application < Rails::Application | |
config.autoload_paths += %W( | |
#{config.root}/app/controllers/concerns | |
#{config.root}/app/models/concerns | |
) | |
end | |
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
# Bulk API design | |
# | |
# resources :posts | |
class PostsController < ActiveController::Base | |
# GET /posts/1,4,50,90 | |
# post_url([ @post, @post ]) | |
def show_many | |
@posts = Post.find(params[:ids]) | |
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 NotesController < ApplicationController | |
def create | |
@note = @project.notes.create params[:note].merge( | |
creator: current_user, subscribers: extract_subscribers(params[:note])) | |
@note.subscribers.each { |subscriber| Subscriptions.note(@note, subscriber).deliver } | |
end | |
end | |
class Subscriptions < ActionMailer::Base |
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
func (h *RESTHandler) finishReq(op *Operation, req *http.Request, w http.ResponseWriter) { | |
result, complete := op.StatusOrResult() | |
obj := result.Object | |
if complete { | |
status := http.StatusOK | |
if result.Created { | |
status = http.StatusCreated | |
} | |
switch stat := obj.(type) { | |
case *api.Status: |
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 Case::AssignmentsController < ApplicationController | |
before_action :set_case, :set_new_owner | |
def create | |
ActiveRecord::Base.transaction do | |
# update case owner | |
@case.update! case_params.merge(owner: @new_owner) | |
# transfer open tasks to new owner | |
@case.tasks.open.each { |task| task.update!(owner: @new_owner) } |
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
module YourApp | |
class Application < Rails::Application | |
# Convenience for loading config/foo.yml for the current Rails env. | |
# | |
# Example: | |
# | |
# config/cleversafe.yml: | |
# | |
# production: | |
# url: http://127.0.0.1:8080 |
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
# Install Git needed for Git based gems | |
packages: | |
yum: | |
git: [] | |
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 'sinatra/base' | |
class FakeGitHub < Sinatra::Base | |
cattr_reader :emulate_failure | |
def self.reset! | |
@@emulate_failure = false | |
end | |
def self.emulate_failure! |
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
{ | |
"id": "d5639304-f15a-48b5-9711-7bd42e6c4d72", | |
"name": "HotelTonight", | |
"legalName": "HotelTonight, Inc", | |
"domain": "hoteltonight.com", | |
"url": "http://hoteltonight.com", | |
"site": { | |
"url": "http://hoteltonight.com", | |
"title": "HotelTonight | Last-Minute Deals on Great Hotels", | |
"h1": "PLAN LESS. ", |
OlderNewer