active record internals - medellin.rb
TRANSCRIPT
Medellín.rbActiveRecord Internals
@RubyMedellinhttp://medellinrb.org
Schedule
- Say Hi- Active Record Pattern- ActiveRecord (Rails)- Yummy yummy- Code Kata
@RubyMedellinhttp://medellinrb.org
Active Record Pattern
An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data.
http://www.martinfowler.com/eaaCatalog/activeRecord.html
ActiveRecord (Rails)Active Record facilitates the creation and use of business objects whose data requires persistent storage to a database. It is an implementation of the Active Record pattern which itself is a description of an Object Relational Mapping system.
http://guides.rubyonrails.org/active_record_basics.html
ActiveRecord (Rails)- ActiveModel- Migrations- Adapters- Validations- Callbacks- etc
http://guides.rubyonrails.org/active_record_basics.html
ActiveRecord (Rails)class Product < ActiveRecord::Base
# ...
end
Product.first
Product.where(name: ‘LCD TV’)
http://guides.rubyonrails.org
class CreateProducts < ActiveRecord::Migration def change create_table :products do |t| t.string :name t.text :description t.timestamps null: false end endend
DEMO
Code will be uploaded to: https://github.com/medellinrb/activerecord-internals
Code KataKata (型 or 形 literally: "form"?), a Japanese word, are the detailed choreographed patterns of movements practised either solo or in pairs.
A code kata is an exercise in programming which helps a programmer hone their skills through practice and repetition.
http://en.wikipedia.org/wiki/Kata_(programming) - http://en.wikipedia.org/wiki/Kata
Today’s KataImplement:
SomeModel.firstSomeModel.allSomeModel.countSomeModel.find_by_name(‘given name’)SomeModel.find_by_whateverattribute(‘xxx’)SomeModel.where(attr: ‘value’)Improve multiple DB adaptersImprove setup/teardown on tests
Thanks <3
Medellín.rb
@RubyMedellinhttp://medellinrb.org