class Dog < ActiveRecord::Base
fido = Dog.new
rex = fido.dup
rex.ball = "tennis"
fido.errors.empty? == false
Ruby Group Tonight @ 6:30
- What is the fastest way to use a calculated column in a where clause with postgres?
SELECT (column1 + column2) AS super_column WHERE super_column > 1
- use a sub query in the FROM
- duplicate the logic for the calculated column
- _before_type_cast lets you get to attributes of a model before they are type cast, useful for validations and calculations.
The week 1 of YYYY starts with a Sunday or Monday (according to %U
or %W). The days in the year before the first week are in week 0.
%U - Week number of the year. The week starts with Sunday. (00..53)
%W - Week number of the year. The week starts with Monday. (00..53)