Skip to content

Instantly share code, notes, and snippets.

View mpattee's full-sized avatar

Mike Pattee mpattee

View GitHub Profile
@mpattee
mpattee / _form.rb
Created February 24, 2012 16:32
Unexpected lack of validation
<ul>
<li><%= f.label :name %>: <%= f.text_field :name %></li>
<li><%= f.label :url %>: <%= f.text_field :url, :size => 100 %></li>
<li><%= f.label :slot %>: <%= f.select :equipmentSlot, @slots %></li>
<li><%= f.label :weight %>: <%= f.text_field :weight %></li>
<li><%= f.label :price %>: <%= f.text_field :price %></li>
<li><%= f.label :rarity %>: <%= f.text_field :rarity %></li>
<li><%= f.label :speed %>: <%= f.text_field :speed %></li>
<li><%= f.label :armor_type %>: <%= f.text_field :armorType %></li>
<li><%= f.label :armor_check %>: <%= f.text_field :armorCheck %></li>
@mpattee
mpattee / gist:1810137
Created February 12, 2012 18:39
test validation in console
Loading development environment (Rails 2.3.11)
>> i = Item.find_by_id(50568)
=> #<Item id: 50568, character_id: 20370, created_at: "2012-02-12 18:13:16", updated_at: "2012-02-12 18:13:16", name: "New Item", url: "", quantity: 2, price: "", weight: "", itemDescription: "">
>> i.quantity = nil
=> nil
>> i.save
=> false
>> i.errors
=> #<ActiveRecord::Errors:0x1035eea08 @base=#<Item id: 50568, character_id: 20370, created_at: "2012-02-12 18:13:16", updated_at: "2012-02-12 18:13:16", name: "New Item", url: "", quantity: nil, price: "", weight: "", itemDescription: "">, @errors=#<OrderedHash {"quantity"=>[#<ActiveRecord::Error:0x1035edd38 @type=:blank, @base=#<Item id: 50568, character_id: 20370, created_at: "2012-02-12 18:13:16", updated_at: "2012-02-12 18:13:16", name: "New Item", url: "", quantity: nil, price: "", weight: "", itemDescription: "">, @attribute=:quantity, @options={:default=>nil}, @message=:blank>]}>>
>>
@mpattee
mpattee / Log
Created February 12, 2012 18:31
My attempt at validation
SQL (0.3ms) SET NAMES 'utf8'
SQL (0.2ms) SET SQL_AUTO_IS_NULL=0
Item Columns (8.7ms) SHOW FIELDS FROM `items`
Item Load (0.3ms) SELECT * FROM `items` WHERE (`items`.`id` = 50568) LIMIT 1
SQL (0.1ms) BEGIN
SQL (0.1ms) ROLLBACK
DEPRECATION WARNING: Giving :session_key to SessionStore is deprecated, please use :key instead. (called from new at /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.11/lib/action_controller/middleware_stack.rb:72)
SQL (0.1ms) SET NAMES 'utf8'
SQL (0.1ms) SET SQL_AUTO_IS_NULL=0