Skip to content

Instantly share code, notes, and snippets.

class ApplicationController...
def clear_cart
@cart.destroy
session[:cart_id] = nil
end
end
class HospitalBooking
def self.send_overtime_mail(user, bookings)
OvertimeMailer.overtime_pdf(user, hospital_booking).deliver
end
end
class SpreadsheetTagService
include Roo
def initialize(uploaded_file)
@spreadsheet = open_spreadsheet(uploaded_file)
do_stuff
end
private
def do_stuff
class Api::TradesController < ApplicationController
respond_to :json
def index
render json: DataTable.new(Trade, params)
end
def create
trade = Trade.new(safe_params)
trade.save
@andyh
andyh / gist:6697426
Created September 25, 2013 09:49 — forked from ebinion/gist:5690817
UPDATE pg_database SET datallowconn = TRUE where datname = 'template0';
\c template0
UPDATE pg_database SET datistemplate = FALSE where datname = 'template1';
drop database template1;
create database template1 with template = template0 encoding = 'UNICODE' LC_CTYPE = 'en_US.UTF-8' LC_COLLATE = 'C';
UPDATE pg_database SET datistemplate = TRUE where datname = 'template1';
\c template1
UPDATE pg_database SET datallowconn = FALSE where datname = 'template0';
@andyh
andyh / ctrl.rb
Last active December 27, 2015 12:39 — forked from anonymous/ctrl.rb
def create
parent_resource = params[:parent_type].constantize
parent_id = params[:parent_id]
# both of the above values are empty because both params are not passed as parameters.
@comment = parent_resource.find(parent_id).comments.create(comment_params.merge(account: current_account))
respond_with :dashboard, @comment
end
@andyh
andyh / comment..rb
Last active December 27, 2015 12:49 — forked from anonymous/comment..rb
def self.create_from_parent(parent_type, parent_id, comment_params, current_account)
raise ActiveRecord::RecordNotFound unless POLYMORPHIC_ON.include?(parent_type)
parent_type.constantize.find(parent_id).comments.create(comment_params.merge(account: current_account))
end
<%= form_for @contact, :remote => true, :url => contacts_path, :html => { :novalidate => '' } do |f| %>
<% if SpreeContactUs.require_name %>
<p>
<%= f.label :name, :class=>'label-field-control' %>
<%= f.text_field :name, class: 'form-control' %>
</p>
<% end %>
<p>
<%= f.label :email, :class=>'label-field-control' %>
@andyh
andyh / rails_resources.md
Created January 16, 2014 20:35 — forked from jookyboi/rails_resources.md
Rails-related Gems and guides to accelerate your web project.

Gems

  • Bundler - Bundler maintains a consistent environment for ruby applications. It tracks an application's code and the rubygems it needs to run, so that an application will always have the exact gems (and versions) that it needs to run.
  • rabl - General ruby templating with json, bson, xml, plist and msgpack support
  • Thin - Very fast and lightweight Ruby web server
  • Unicorn - Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels.
  • SimpleCov - SimpleCov is a code coverage analysis tool for Ruby 1.9.
  • Zeus - Zeus preloads your Rails app so that your normal development tasks such as console, server, generate, and specs/tests take less than one second.
  • [factory_girl](h
@andyh
andyh / css_resources.md
Created January 16, 2014 20:35 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides