Tag Archives: ActiveRecord

Testing DateTime ActiveRecord validation callback

#!/usr/bin/env ruby require ‘active_record’ require ‘rspec’ DB_SPEC = { :adapter => “sqlite3″, :database => “artest.db”, :pool => 5, :timeout => 5000 } ActiveRecord::Base.establish_connection(DB_SPEC) class Users < ActiveRecord::Migration def self.up create_table :users do |t| t.string :name t.datetime :startdate t.datetime :finishdate end end def self.down drop_table :users end end unless Users.table_exists?(:users) ActiveRecord::Migrator.migrate(Users.up) end class User < ActiveRecord::Base […]

Posted in rails | Also tagged , , | 1 Response

Code Kata Fat Model Validating Presence

[Revised July 31, 2011] Code kata is a powerful weapon in your programming arsenal; probably the most powerful weapon in mine. The deliberate practice of programming using the code kata technique acknowledges the truth: “Simple things are hard enough.” In Rails programming, using the Fat Model Skinny Controller paradigm, models occupy a lot of attention […]

Posted in rails | Also tagged , , , | Leave a comment

DEPRECATION WARNING: Errors#on have been deprecated

Here’s something which really bugs me: I do a search on something like an error message (e.g., article title), and the whole front page of Google comes back with garbage. Even Stack Overflow is on the second page for this “errors on versus errors :field” problem. It makes me want to write a stupid blog […]

Posted in rails | Also tagged , | 2 Responses