Vincent Tsao's Library tagged → View Popular
Active Record Query Interface
-
Behind the scenes find_each fetches rows in batches of 1000 and yields them one by one. The size of the underlying batches is configurable via the :batch_size option.
To fetch User records in batch size of 5000:
-
User.find_each(:batch_size => 5000) do |user|
NewsLetter.weekly_deliver(user)
end - 1 more annotations...
Active Record Validations and Callbacks
-
17 Observers
Observers are similar to callbacks, but with important differences. Whereas callbacks can pollute a model with code that isn’t directly related to its purpose, observers allow you to add the same functionality outside of a model. For example, it could be argued that a User model should not include code to send registration confirmation emails. Whenever you use callbacks with code that isn’t directly related to your model, you may want to consider creating an observer instead.
Eli Bendersky’s website » Blog Archive » Understanding Ruby blocks, Procs and methods
-
Procs play the role of functions in Ruby. It is more accurate to call them function objects, since like everything in Ruby they are objects. Such objects have a name in the folklore - functors. A functor is defined as an object to be invoked or called as if it were an ordinary function, usually with the same syntax, which is exactly what a Proc is.
-
Actually, there are two slight differences between
lambdaandProc.new. First, argument checking. The Ruby documentation forlambdastates: Equivalent to Proc.new, except the resulting Proc objects check the number of parameters passed when called.. Here is an example to demonstrate this: - 6 more annotations...
Selected Tags
Related Tags
Top Contributors
Groups interested in ruby
-
Ruby Stduy
start to study ruby
Items: 18 | Visits: 106
Created by: swan lin
-
ror-project
Items: 1 | Visits: 104
Created by: A. D.
-
Rspec Intro
RSpec is a Behaviour Driven...
Items: 11 | Visits: 234
Created by: Vincent Tsao
Highlighter, Sticky notes, Tagging, Groups and Network: integrated suite dramatically boosting research productivity. Learn more »
Join Diigo
