Skip to content

Instantly share code, notes, and snippets.

@cain-alchemist
cain-alchemist / controller.rb
Created November 7, 2011 12:48
Receita Alquímica: O Velho Problema do Botão de Voltar do Browser - Gist for AlchemyLab Blog.
#Após inserir o método set_no_cache no application controller coloque um before filter no controller que você
#quiser validar
before_filter :set_no_cache
#Você pode utilizar a versão abaixo, validando apenas as ações que você quiser
before_filter :set_no_cache, :only => [ :edit, :update ]
@cain-alchemist
cain-alchemist / application_controller.rb
Created November 7, 2011 12:45
Receita Alquímica: O Velho Problema do Botão de Voltar do Browser - Gist for AlchemyLab Blog.
def set_no_cache
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
end
@cain-alchemist
cain-alchemist / gist:1320565
Created October 27, 2011 19:21
remarkable_test: character.rb
class Character < ActiveRecord::Base
validates_presence_of :name, :race, :cclass, :age
validates_length_of :name, :in => 4..100
validates_length_of :race, :in => 6..50
validates_numericality_of :age
end
@cain-alchemist
cain-alchemist / gist:1320561
Created October 27, 2011 19:20
remarkable_test: Executing RSpec
bundle exec rspec spec
@cain-alchemist
cain-alchemist / gist:1320557
Created October 27, 2011 19:19
remarkable_test: character_spec.rb
require 'spec_helper'
describe Character do
before(:all) do
Character.create(name: "Ulrich", race: "Human", cclass: "Fighter", age: 20)
end
it "Should Validade the Presence of Name, Race, Class and Age at one Character"do
should validate_presence_of :name,:race, :cclass, :age
end
it "Name should have a range of 4 to 100 characters" do
@cain-alchemist
cain-alchemist / gist:1320545
Created October 27, 2011 19:16
remarkable_test: Annotate
bundle exec annotate
@cain-alchemist
cain-alchemist / gist:1320539
Created October 27, 2011 19:15
remarkable_test: Migrating Tests
rake db:test:prepare
@cain-alchemist
cain-alchemist / gist:1320537
Created October 27, 2011 19:14
remarkable_test: Migrating the Database
rake db:migrate
@cain-alchemist
cain-alchemist / gist:1320534
Created October 27, 2011 19:13
remarkable_test: Creating the Databases
rake db:create:all
@cain-alchemist
cain-alchemist / gist:1320530
Created October 27, 2011 19:13
remarkable_test: Generating the Models and Test
rails generate model Character name:string race:string cclass:string age:integer