• Like
  • Save
浜松Rails3道場 其の弐 Model編
Upcoming SlideShare
Loading in...5
×
 

浜松Rails3道場 其の弐 Model編

on

  • 1,678 views

 

Statistics

Views

Total Views
1,678
Views on SlideShare
1,673
Embed Views
5

Actions

Likes
1
Downloads
17
Comments
0

2 Embeds 5

http://twitter.com 4
https://twitter.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    浜松Rails3道場 其の弐 Model編 浜松Rails3道場 其の弐 Model編 Presentation Transcript

    • Model Hamamatsurb#5 2011.07.13 @mackato2011 7 13
    • 2011 7 13
    • Wiki 52011 7 13
    • 2011 7 13
    • 2011 7 13
    • 2011 7 13
    • 2011 7 13
    • Model - Ruby on Rails Guides Rails Database Migrations: http://bit.ly/rrH5zQ Active Record Validations and Callbacks: http://bit.ly/qp5vkm Active Record Associations: http://bit.ly/n3exu9 Active Record Query Interface: http://bit.ly/qaeazJ2011 7 13
    • Version 1.9.2 Version 3.0.7 .rvmrc rvm ruby-1.9.2-p180@rails-3_0_72011 7 13
    • GitHub git clone git://github.com/hamamatsu-rb/rails3dojo.git git checkout -b working 2-model_pre2011 7 13
    • FactoryGirl( ) Spork( ) Gemfile .rspec Spork spork --bootstrap2011 7 13
    • Wiki User: Wiki Page: Wiki Comment: Page History: Page2011 7 13
    • Wiki rails g model user name:string rake db:migrate2011 7 13
    • spec/factories.rb spec/spec_helper.rb2011 7 13
    • spec/models/user_spec.rb2011 7 13
    • app/models/user.rb SexyValidation! Legacy Style Validation2011 7 13
    • bundle exec rspec spec/models/user_spec.rb User #name 50 #find_or_create_by_name2011 7 13
    • Wiki rails g model page title:string body:text user_id:integer rake db:migrate2011 7 13
    • spec/factories.rb spec/spec_helper.rb2011 7 13
    • spec/models/page_spec.rb( )2011 7 13
    • app/models/page.rb2011 7 13
    • Page rails g model comment body:text page_id:integer user_id:integer rake db:migrate2011 7 13
    • spec/factories.rb spec/spec_helper.rb2011 7 13
    • spec/models/comment_spec.rb( )2011 7 13
    • app/models/comment.rb2011 7 13
    • spec/models/page_spec.rb ( ) app/models/page.rb2011 7 13
    • Page rails g model history page_id:integer user_id:integer rake db:migrate2011 7 13
    • spec/factories.rb spec/spec_helper.rb2011 7 13
    • spec/models/history_spec.rb2011 7 13
    • app/models/history.rb2011 7 13
    • spec/models/page_spec.rb ( ) app/models/page.rb2011 7 13
    • spec/models/page_spec.rb ( ) app/models/page.rb2011 7 13
    • master git checkout master git merge working git branch -d working GitHub git clone git://github.com/hamamatsu-rb/rails3dojo.git git checkout 2-model2011 7 13
    • 2011 7 13
    • page db/migrate/20110712154821_create_pages.rb rake db:migrate [VERSION=YY..] rake db:rollback [STEP=N] rake db:migrate:redo [STEP=N] page2011 7 13
    • Validation Helpers vs SexyValidation2011 7 13
    • The belongs_to Association The has_many :through Association class  Order  <  ActiveRecord::Base    belongs_to  :customer class  Physician  <  ActiveRecord::Base end    has_many  :appointments    has_many  :patients,  :through  =>  :appointments end The has_one Association   class  Appointment  <  ActiveRecord::Base class  Supplier  <  ActiveRecord::Base    belongs_to  :physician    has_one  :account    belongs_to  :patient end end   class  Patient  <  ActiveRecord::Base    has_many  :appointments The has_many Association    has_many  :physicians,  :through  =>  :appointments end class  Customer  <  ActiveRecord::Base    has_many  :orders end : Active Record Associations: http://bit.ly/n3exu92011 7 13
    • Finder methods Retrieving a Single Object • where • select • group • order Retrieving Multiple Objects • limit • offset • joins • includes • lock Calculations • readonly • from • having Active Record Query Interface: http://bit.ly/qaeazJ2011 7 13
    • 2011 7 13
    • 2011 7 13
    • 2011 7 13
    • 2011 7 13