Rails 3 Ropes Course: Gregg Pollack ppt

86 292 0
Rails 3 Ropes Course: Gregg Pollack ppt

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Rails 3 Ropes Course Gregg Pollack Nathaniel Bibler Thomas Meeks Jacob Swanner Mark Kendall Caike Souza Tyler Hunt Getting Started & Routes Workshop - Lab #1 Bundler & ActionController Workshop - Lab #2 ActionMailer Workshop - Lab #3 ActiveRelation & ActiveModel Workshop - Lab #4 XSS & UJS Workshop - Lab #5 Rails 3 Ropes Course !"#$%&' Starting a New App ('$)*+ ""#$%&'", ,/0"1234%25'6 734%25'+ 89:5;&* ;9<=8'>&%4*? &2)<=8&2) 4@3<==<= .gitignore """"""1AA;*B6""""""""""""""""C"D*4:3"4E*"$33&%F$4%25"G%4E" """""""""""""""""""""""""""""C"H*@I%&*"32%54%5)"42"J2:#"K$%&'"FE*FL2:4 """"""1AA*;)*6"""""""""""""""C"D*4:3"4E*"$33&%F$4%25"G%4E" """""""""""""""""""""""""""""C"H*@I%&*"32%54%5)"42"K$%&'"#*32'%42#J 1AA'L%3A)*@I%&*6"""""""C"M25N4"F#*$4*"$"H*@I%&* ""A#O"1AA#:9JP-,/06""""""""""C"-$4E"42"4E*"K:9J"9%5$#J"2I"J2:#"FE2%F* ""A;O"1AA;$4$9$'*PM,/,Q,DR6""C"-#*F25I%):#*"I2#"'*&*F4*;";$4$9$'*"""""""""""""""""""""""""""""" ""A@O"1AA4*@3&$4*P/RS-T,/R6""C"-$4E"42"$5"$33&%F$4%25"4*@3&$4*" A7O"1AA'L%3A$F4%B*#*F2#;6""C"DL%3",F4%B*K*F2#;"I%&*' A/O"1AA'L%3A4*'4:5%46""""""C"DL%3"/*'4(5%4"I%&*' AUO"1AA'L%3A3#2424J3*6"""""C"DL%3"-#2424J3*"I%&*' AHO"1AA'L%3A)%46"""""""""""C"DL%3"H%4"%)52#*'"$5;"L**3' !"#$%&'"4*'4.$33 """"""F#*$4*"" """"""F#*$4*""KR,MSR """"""F#*$4*""8)%4%)52#* """"""888 !"#$%&' ('$)*+"#$%&'"V7SS,WM"1,KHD6 /E*"@2'4"F2@@25"#$%&'"F2@@$5;'"$#*+ ")*5*#$4*""""H*5*#$4*"5*G"F2;*"X'E2#4AF:4"$&%$'+"Y)YZ F25'2&*"""""D4$#4"4E*"K$%&'"F25'2&*"X'E2#4AF:4"$&%$'+"YFYZ '*#B*#""""""D4$#4"4E*"K$%&'"'*#B*#"X'E2#4AF:4"$&%$'+"YDYZ ;9F25'2&*"""D4$#4"$"F25'2&*"I2#"4E*";$4$9$'*"'3*F%I%*;"%5"F25I%)<;$4$9$'*8J@& """"""""""""X'E2#4AF:4"$&%$'+"Y;9YZ [5"$;;%4%25"42"4E2'*O"4E*#*"$#*+ "$33&%F$4%25""H*5*#$4*"4E*"K$%&'"$33&%F$4%25"F2;* ";*'4#2J""""""(5;2"F2;*")*5*#$4*;"G%4E"Y)*5*#$4*Y "9*5FE@$#L*#""D**"E2G"I$'4"$"3%*F*"2I"F2;*"#:5' "3#2I%&*#"""""H*4"3#2I%&*"%5I2#@$4%25"I#2@"$"3%*F*"2I"F2;* "3&:)%5"""""""[5'4$&&"$"3&:)%5 "#:55*#"""""""K:5"$"3%*F*"2I"F2;*"%5"4E*"$33&%F$4%25"*5B%#25@*54 ,&&"F2@@$5;'"F$5"9*"#:5"G%4E"AE"I2#"@2#*"%5I2#@$4%258 !"&'"'F#%34< "" ""#$%&' !"F;"4*'4.$33< script/generate script/console script/server old scripts new hotness script/dbconsole rails1g rails1c rails1s rails1db script/generate script/console script/server old scripts new hotness script/dbconsole $&%$'"#PN#$%&'N r1g r1c r1s r1db Rails::Initializer.run do |config| end config/environment.rb configuration Rails 2 config.load_paths += %W( #{RAILS_ROOT}/extras ) config.plugins = [ :exception_notification ] config.time_zone = 'UTC' config.gem "bj" config.gem "sqlite3-ruby", :lib => "sqlite3" config.gem "aws-s3", :lib => "aws/s3" Gemfile config/application.rb configuration Rails 3 config.load_paths += %W( #{RAILS_ROOT}/extras ) config.plugins = [ :exception_notification ] config.time_zone = 'UTC' Gemfile module TestApp class Application < Rails::Application end end It’s a Rack Application New Router API Action Dispatch Layouts Logger Callbacks Renderer url_for http_auth helpers MimeResponds Cookies Session http routing middleware [...]...  >=  2 .3. 2 System  Gems Rails  2 .3. 2 ac@vesupport  =  2 .3. 2 Rails  App Rails  2 .3. 2 Rails  2 .3. 3 thor  0. 13. 1 Ac@veMerchant  1.4.2 appy! H Dependency Resolution Depth First Search dependencies paperclip shoulda mocha searchlogic sqlite3 rake-compiler aws-s3 activerecord Conflict Gemfile Syntax source "http://rubygems.org" gem gem gem gem "hpricot", "0.6" "sqlite3-ruby", :require => "sqlite3" "rails" ,... ac@vesupport  >=  2 .3. 2 Rails  2 .3. 2 ac@vesupport  =  2 .3. 2 Rails  App System  Gems Ac@veMerchant  1.4.2 Rails  2 .3. 3 Rails  2 .3. 2 2, (= 2 .3 rt esuppo 3 v rt-2 .3 e acti ppo vat tivesu t acti an' d ac thor  0. 13. 1 ror: c tivate ac adEr lready em::Lo G , a ntime) ru Bundler Commands Specify  your  gems  inside  Gemfile gem "haml" gem "chronic", '0.2 .3' $  bundle fetch,  download,  and  install/compile  these... Rails 2 map.root :controller => 'users', :action => 'index' Rails 3 root :to => 'users#index' Legacy Route Rails 2 map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' Rails 3 match ':controller(/:action(/:id(.:format)))' (commented out by default) Optional Parameters Rails 2 map.connect '/articles/:year/:month/:day', :controller => 'posts', :action => 'index' Rails 3. .. end Rails 3 New Routing API config/routes.rb TestApp::Application.routes.draw do |map| map.resources :posts end Old routing syntax works Rails 3 New Routing API Rails 2 map.resources :posts do |post| post.resources :comments end Rails 3 resources :posts do resources :comments end New Routing API Rails 2 post.resources :comments, :member => { :preview => :post }, :collection => { :archived => :get } Rails. .. Rails 3 resources :comments do member do post :preview end collection do get :archived end end Rails 3 resources :comments do post :preview, :on => :member get :archived, :on => :collection end Rails 2 map.connect 'login', :controller => 'session', :action => 'new' Rails 3 match 'login' => 'session#new' Named Route login_path Rails 2 map.login 'login', :controller => 'session', :action => 'new' Rails 3. .. :action => 'index', :conditions => {:method => :get} Rails 3 match '/articles/:year' => "posts#index", :via => :get Rails 3 get '/articles/:year' => "posts#index" Redirection Rails 3 match 'signin', :to => redirect("/login") match 'users/:name', :to => redirect {|params| "/#{params[:name]}" } match 'google' => redirect('http://www.google.com/') Constraints Rails 2 map.connect '/:year', :controller => 'posts',... information http://guides .rails. info/routing.html Tutorial - Lab #1 Getting Started & Routes Follow the directions in the README Rails 3 Ropes Course Getting Started & Routes Workshop - Lab #1 Bundler & ActionController Workshop - Lab #2 ActionMailer Workshop - Lab #3 ActiveRelation & ActiveModel Workshop - Lab #4 XSS & UJS Workshop - Lab #5 Dependency Management Typical Rails deployment Specify  your... activerecord Conflict Gemfile Syntax source "http://rubygems.org" gem gem gem gem "hpricot", "0.6" "sqlite3-ruby", :require => "sqlite3" "rails" , :git => "git://github.com /rails/ rails.git" "rails" , :path => "~/Sites /rails" git "git://github.com /rails/ rails.git" do gem "railties" gem "active_model" end group :test do gem "webrat" end $bundle Will ensure all gems are installed, including webrat (but it’s only included... '0.2 .3' $  rake  gems:install fetch,  download,  and  install/compile  these   gems  into  your  system  RubyGems  directory $  rake  gems:unpack:dependencies unpacks  the  gems  into  your  applica@on   into  your  vendor/gems  directory Issues It’s bound into Rails Not great dependency resolution occur at runtime Conflicts Dependency Resolution Ac@veMerchant  1.4.2 ac@vesupport  >=  2 .3. 2 Rails  2 .3. 2... :requirements => { :year => /\d{4}/ } Rails 3 match '/:year' => "posts#index", :constraints => {:year => /\d{4}/} :constraints => { :user_agent => /iphone/ } :constraints => { :ip => /192\.168\.1\.\d{1 ,3} / } constraints(:host => /localhost/) do resources :posts end constraints IpRestrictor do get 'admin/accounts' => "queenbee#accounts" end Rack Goodness Rails 3 get 'hello' => proc { |env| [200, {}, . ,/0"1 234 %25'6 734 %25'+ 89:5;&* ;9<=8'>&%4*? &2)<=8&2) 4 @3& lt;==<= .gitignore """"""1AA;*B6""""""""""""""""C"D*4 :3& quot;4E*" $33 &%F$4%25"G%4E" """""""""""""""""""""""""""""C"H*@I%&*" ;32 %54%5)"42"J2:#"K$%&'"FE*FL2:4 """"""1AA*;)*6"""""""""""""""C"D*4 :3& quot;4E*" $33 &%F$4%25"G%4E" """""""""""""""""""""""""""""C"H*@I%&*" ;32 %54%5)"42"K$%&'"# *32 '%42#J 1AA'L%3A)*@I%&*6"""""""C"M25N4"F#*$4*"$"H*@I%&* ""A#O"1AA#:9JP-,/06""""""""""C"-$4E"42"4E*"K:9J"9%5$#J"2I"J2:#"FE2%F* ""A;O"1AA;$4$9$'*PM,/,Q,DR6""C"-#*F25I%):#*"I2#"'*&*F4*;";$4$9$'*"""""""""""""""""""""""""""""" ""A@O"1AA4* @3& amp;$4*P/RS-T,/R6""C"-$4E"42"$5" $33 &%F$4%25"4* @3& amp;$4*" A7O"1AA'L%3A$F4%B*#*F2#;6""C"DL %3& quot;,F4%B*K*F2#;"I%&*' A/O"1AA'L%3A4*'4:5%46""""""C"DL %3& quot;/*'4(5%4"I%&*' AUO"1AA'L%3A3#2424J3*6"""""C"DL %3& quot;-#2424J3*"I%&*' AHO"1AA'L%3A)%46"""""""""""C"DL %3& quot;H%4"%)52#*'"$5;"L* *3& apos; !"#$%&'"4*'4. $33 """"""F#*$4*"" """"""F#*$4*""KR,MSR """"""F#*$4*""8)%4%)52#* """"""888 !"#$%&' ('$)*+"#$%&'"V7SS,WM"1,KHD6 /E*"@2'4"F2@@25"#$%&'"F2@@$5;'"$#*+ ")*5*#$4*""""H*5*#$4*"5*G"F2;*"X'E2#4AF:4"$&%$'+"Y)YZ F25'2&*"""""D4$#4"4E*"K$%&'"F25'2&*"X'E2#4AF:4"$&%$'+"YFYZ '*#B*#""""""D4$#4"4E*"K$%&'"'*#B*#"X'E2#4AF:4"$&%$'+"YDYZ ;9F25'2&*"""D4$#4"$"F25'2&*"I2#"4E*";$4$9$'*"&apos ;3* F%I%*;"%5"F25I%)<;$4$9$'*8J@& """"""""""""X'E2#4AF:4"$&%$'+"Y;9YZ [5"$;;%4%25"42"4E2'*O"4E*#*"$#*+ " $33 &%F$4%25""H*5*#$4*"4E*"K$%&'" $33 &%F$4%25"F2;* ";*'4#2J""""""(5;2"F2;*")*5*#$4*;"G%4E"Y)*5*#$4*Y "9*5FE@$#L*#""D**"E2G"I$'4"$" ;3% *F*"2I"F2;*"#:5' " ;3# 2I%&*#"""""H*4" ;3# 2I%&*"%5I2#@$4%25"I#2@"$" ;3% *F*"2I"F2;* " ;3& amp;:)%5"""""""[5'4$&&"$" ;3& amp;:)%5 "#:55*#"""""""K:5"$" ;3% *F*"2I"F2;*"%5"4E*" $33 &%F$4%25"*5B%#25@*54 ,&&"F2@@$5;'"F$5"9*"#:5"G%4E"AE"I2#"@2#*"%5I2#@$4%258 !"&'"'F# %34 < "" ""#$%&' !"F;"4*'4. $33 < script/generate script/console script/server old. => :login Rails 2 Rails 3 Named Route login_path map.root :controller => 'users', :action => 'index' Rails 2 Rails 3 root :to

Ngày đăng: 16/03/2014, 11:20

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan