This file contains hidden or 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
| #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 ] |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| bundle exec rspec spec |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| bundle exec annotate |
This file contains hidden or 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
| rake db:test:prepare |
This file contains hidden or 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
| rake db:migrate |
This file contains hidden or 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
| rake db:create:all |
This file contains hidden or 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
| rails generate model Character name:string race:string cclass:string age:integer |
NewerOlder