Let's look at an innocuous piece of ruby. Consider some view code showing a user's name and phone number:
"#{first_name} #{last_name} #{phone}"
Great - this is very succinct, readable, and can easily be extracted to a method in a
HTTP status code symbols for Rails | |
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
Status Code Symbol | |
1xx Informational | |
100 :continue | |
101 :switching_protocols | |
102 :processing |
class DummyController < ApplicationController | |
def do | |
render json: { balance: 50 } | |
end | |
end |
describe 'Expectation Matchers' do | |
describe 'equivalence matchers' do | |
it 'will match loose equality with #eq' do | |
a = "2 cats" | |
b = "2 cats" | |
expect(a).to eq(b) | |
expect(a).to be == b # synonym for #eq |
#!/usr/bin/env ruby | |
require "openssl" | |
require "time" | |
begin | |
require "origami" | |
rescue LoadError | |
abort "origami not installed: gem install origami" | |
end |
<%# Put this code snippet between the <head></head>-tags in your application layout and %> | |
<%# replace 'UA-XXXXXXXX-X' with your own unique Google Analytics Tracking ID %> | |
<%# ... %> | |
<head> | |
<%# ... %> | |
<% if Rails.env.production? %> | |
<script type="text/javascript"> | |
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
$(function () { | |
//Config datepiker matrializecss () language | |
$('.datepicker').pickadate({ | |
selectMonths: true,//Creates a dropdown to control month | |
selectYears: 15,//Creates a dropdown of 15 years to control year | |
//The title label to use for the month nav buttons | |
labelMonthNext: 'Proximo Mês', | |
labelMonthPrev: 'Mês Anterior', | |
//The title label to use for the dropdown selectors | |
labelMonthSelect: 'Selecionar Mês', |
Short (72 chars or less) summary
More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).
Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
module WillPaginate | |
module ActionView | |
def will_paginate(collection = nil, options = {}) | |
options[:renderer] ||= BootstrapLinkRenderer | |
super.try :html_safe | |
end | |
class BootstrapLinkRenderer < LinkRenderer | |
protected |
# Sample reference code for doubles/mocks, stubs, and spies in RSpec | |
# Taken from Kevin Skoglund's RSpec tutorial on Lynda.com | |
describe 'Doubles' do | |
it "allows stubbing methods" do | |
dbl = double("Chant") | |
allow(dbl).to receive(:hey!) | |
expect(dbl).to respond_to(:hey!) | |
end |