Skip to content

Instantly share code, notes, and snippets.

View coderdan's full-sized avatar

Dan Draper coderdan

View GitHub Profile
def add_constraints(scope)
tables = construct_tables
chain.each_with_index do |reflection, i|
table, foreign_table = tables.shift, tables.first
if reflection.source_macro == :has_and_belongs_to_many
join_table = tables.shift
scope = scope.joins(join(
logformat squid %{%s}tl %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mt
access_log daemon:/var/log/squid/access.log squid
logfile_daemon /usr/bin/squid_log_writer
curl -X POST -F "key=<key-here>" -F "hostname=test.host&version=1&h" -F "host_string=foo" -F "version=1" http://collector.dev.netfox.com/poller
class CandidateStatusEnumeration
def self.default
DEFAULT_ONE
end
def self.default_status
ActiveSupport::Deprecation.warn('Use default instead')
default
end
RSpec.describe LikertInput, type: :input do
class MockTemplate
include ActionView::Helpers
attr_accessor :output_buffer
end
let(:object) { double(:object, happiness: '1') }
let(:builder) { double(:builder, object: object) }
let(:input_options) { { value: '1', class: 'input-small' } }
@coderdan
coderdan / rails-template.rb
Last active August 29, 2015 14:07
JobReady Service Application Template
# TODO: Bower initializer, dotenv at top, oauth/doorkeeper stuff
add_source 'https://nQPUkxkYvJdhiX87ansa@gem.fury.io/jobready/'
gem 'dotenv-rails'
multi = yes?('Does this app need multitenancy?')
sidekiq = yes?('Does this app need background processing with sidekiq?')
api_access = yes?('Is API access needed?')
def create
@form = ReminderForm.new(remindable.reminders.build)
if @form.validate(reminder_params)
@form.save do |params|
ReminderCreator.new(current_user, remindable, params).perform
redirect_to :back, notice: "Reminder '#{@form.title}' created successfully."
end
else
render :new
end
puts "Hello World"
Started POST "/events" for 59.167.130.80 at 2015-06-29 04:45:23 +0000
Processing by EventsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"1I+XIaiEAOacU+eoAVz5BU/1LILv7lDBDCQahCWMPUe5PCxRu2NFNfDT68tPhxM3yCtYNKWT0byB96Am+LDLZQ==", "event"=>{"event_name"=>"Simple 1", "start_time(1i)"=>"2015", "start_time(2i)"=>"6", "start_time(3i)"=>"30", "time_slot_ids"=>["1", "2", ""]}, "commit"=>"Create my event"}
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]]
Unpermitted parameter: time_slot_ids
(0.1ms) begin transaction
SQL (0.4ms) INSERT INTO "events" ("event_name", "start_time", "user_id", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) [["event_name", "Simple 1"], ["start_time", "2015-06-30 00:00:00.000000"], ["user_id", 1], ["created_at", "2015-06-29 04:45:23.392162"], ["updated_at", "2015-06-29 04:45:23.392162"]]
(8.3ms) commit transaction
Redirected to https://togs-twitter2-tmehta2442.c9.io/events/41
Completed 302 Found in 16m
class CustomerAPI < Grape::API
version 'v1', :using => :header
resource :users do
desc "Return all users"
get do
User.all
end
desc "Return a User with a given ID"