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.
Softies on Rails: Ruby 201: Weird Hash Syntax
-
vehicles = { :cars => 36, :boats => 8, :trains => 12, :planes => 21 }
vehicles.select { |k,v| v > 20 }
=> [[ :planes, 21], [ :cars, 36]] -
a = [[:planes, 21], [:cars, 36]].flatten
=> [ :planes, 21, :cars, 36] - 5 more annotations...
Selected Tags
Related Tags
Top Contributors
Groups interested in rails
-
ror-project
Items: 1 | Visits: 104
Created by: A. D.
-
Rails ActiveMessaging Intro
message plugin for rails
Items: 11 | Visits: 227
Created by: Vincent Tsao
-
Rails Plugins
Items: 4 | Visits: 67
Created by: Vincent Tsao
Highlighter, Sticky notes, Tagging, Groups and Network: integrated suite dramatically boosting research productivity. Learn more »
Join Diigo
