NOTE I now use the conventions detailed in the SUIT framework
Used to provide structural templates.
Pattern
t-template-name
/** | |
* Annotated Gruntfile. | |
* This builds a Backbone/Marionette application using Dust.js (Linkedin fork) as a | |
* templating system, as well as some helpers from Foundation, with Browserify. | |
* It also configures a watcher and static server with live reload. | |
*/ | |
module.exports = function (grunt) { | |
// This automatically loads grunt tasks from node_modules | |
require("load-grunt-tasks")(grunt); |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Building a router</title> | |
<script> | |
// Put John's template engine code here... | |
(function () { | |
// A hash to store our routes: |
# Main reference was lascarides' post at http://stackoverflow.com/questions/14743447/getting-pdf-from-wickedpdf-for-attachment-via-carrierwave | |
# estimate.rb | |
# ... | |
has_attached_file :pdf, | |
storage: :s3, | |
s3_credentials: { | |
access_key_id: ENV['AWS_ACCESS_KEY_ID'], | |
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'], | |
bucket: ENV['AWS_BUCKET'] |
# If you are using the MySQL 5.6 version of mysqldump on an older MySQL database, you might get the error message. | |
mysqldump: Couldn't execute 'SELECT @@GTID_MODE': Unknown system variable 'GTID_MODE' (1193) | |
# This error is in part due to the introduction of Global Transaction Identifiers (GTIDs) in MySQL 5.6. GTIDs make it simple to # track and compare replication across a master-slave topology. | |
# mysqldump tries to query this system variable, which doesn’t exist in earlier versions, and then fails. The solution is to add # –set-gtid-purged=OFF in the mysqldump command. It should look something like | |
mysqldump -h dbHost -u dbuser dbName --set-gtid-purged=OFF |
# Support for Rspec / Capybara subdomain integration testing | |
# Make sure this file is required by spec_helper.rb | |
# (e.g. save as spec/support/subdomains.rb) | |
def switch_to_subdomain(subdomain) | |
# lvh.me always resolves to 127.0.0.1 | |
hostname = subdomain ? "#{subdomain}.lvh.me" : "lvh.me" | |
Capybara.app_host = "http://#{hostname}" | |
end |
group :production do | |
gem "unicorn" | |
end |
# Support for Rspec / Capybara subdomain integration testing | |
# Make sure this file is required by spec_helper.rb | |
# | |
# Sample subdomain test: | |
# it "should test subdomain" do | |
# switch_to_subdomain("mysubdomain") | |
# visit root_path | |
# end | |
DEFAULT_HOST = "lvh.me" |
#Model | |
@user.should have(1).error_on(:username) # Checks whether there is an error in username | |
@user.errors[:username].should include("can't be blank") # check for the error message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |
NOTE I now use the conventions detailed in the SUIT framework
Used to provide structural templates.
Pattern
t-template-name
module Mongoid | |
module Document | |
def as_json(options={}) | |
attrs = super options | |
attrs["id"] = attrs.delete "_id" if attrs.has_key? "_id" | |
attrs | |
end | |
end | |
end |