View apple_pay_in_browser.js
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
function applePayButtonClicked(event) | |
{ | |
var paymentRequest = { | |
// countryCode: The merchant’s ISO country code. | |
countryCode: 'US', | |
// currencyCode: The ISO currency code for the payment. | |
currencyCode: 'USD', | |
// total: The total amount for the payment. | |
total: { | |
label: 'Canine Clothing', |
View rails_bug_has_many_through_with_foreign_key.rb
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
begin | |
require 'bundler/inline' | |
rescue LoadError => e | |
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' | |
raise e | |
end | |
gemfile(true) do | |
source 'https://rubygems.org' | |
gem 'activerecord', '4.2.0' |
View capybara_cheat_sheet.rb
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
#=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
#=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click_on('Button Value') |
View hstore_getter_setter.rb
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 HstoreSetterGetter | |
# To use simply add to your models: | |
# | |
# include HstoreSetterGetter | |
# hstore_attributes :test1, :test2, type: :integer #assumes column_name: :data | |
# hstore_attributes :test3, :test4, column_name: :properties #assumes type: :string | |
# | |
# Written by Michael Elfassy | |
# http://napps.ca | |
# |
View clone_rails.thor
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
#!/usr/bin/env ruby | |
require "rubygems" # ruby1.9 doesn't "require" it though | |
require "thor" | |
class CloneRails < Thor | |
include Thor::Actions | |
desc "new NAME, TEMPLATE", "Create a new rails app based on a template app" | |
method_options :template => "template" | |
def new(name) | |
puts "Copying the template..." |
View setup_template.rb
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
# Setup a template that can be cloned later | |
# Command: | |
# rails new NAME -m setup_template.rb | |
# (by default you should use "template" as NAME) | |
plugin("Rename", :git => "git@github.com:get/Rename.git") | |
# See http://everydayrails.com/2011/02/28/rails-3-application-templates.html if you need more customization of the template generator |
View image_tag_helper.rb
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
#Orverwrite the image_tag based on the idea from Designer Wall (http://webdesignerwall.com/tutorials/css3-image-styles) | |
def image_tag(source, options = {}) | |
image_width = image_height = nil | |
image_width_css = image_height_css = "" | |
options.symbolize_keys! | |
options[:class] = "image-wrap " + options[:class] |