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 'benchmark' | |
require 'benchmark/ips' | |
GC.disable | |
UNSAFE_STRING_METHODS = %w( | |
capitalize chomp chop delete downcase gsub lstrip next reverse rstrip | |
slice squeeze strip sub succ swapcase tr tr_s upcase prepend | |
) |
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
This gist is in reference to the documentation for the Rails 3.2.13 on Ruby 1.9.3 p194 (http://guides.rubyonrails.org/active_record_validations_callbacks.html#on) where it has highlighted the fact that the validations for presence can also be run using the :on => :save option. The following code will highlight it better | |
class User < ActiveRecord::Base | |
attr_accessible :name | |
validates :name, :presence => true, :on => :save | |
end | |
u = User.create | |
u.errors #=> nil |
The audited gem is a powerful gem that helps us keeping the log of the changes that are made to the models. This gem does its job excellently but there are some issues which I have discovered when I was reading this gem..
Suppose I have a model named Customer as shown below
class Customer < ActiveRecord::Base
attr_accessible :first_name
audited comment_required: true
end