SlideShare une entreprise Scribd logo
1  sur  44
Télécharger pour lire hors ligne
Routing
Hamamatsurb#4 2011.06.08 @mackato
Wiki or CMS
    5
Routing
Version 1.9.2

             Version 3.0.7

.rvmrc
rvm ruby-1.9.2-p180@rails-3_0_7
rails new rails3dojo -m http://railswizard.org/ae25c16f22597ad5ea98.rb -J -T
≠ CSS   ≠ Erb
Gemfile
gem 'rake', '0.8.7'




    gem uninstall rake -v=0.9.x
    bundle update
          ※ Rails3.1   0.9.1   OK!
Mac only!




cd ~/.pow
ln -s /path/to/rails3dojo
open http://rails3dojo.dev/
http://localhost:3000/




rm public/index.html public/images/rails.png
http://localhost:3000/




     Routing
HTTP




         Methods: GET, POST, PUT, DELETE
         Paths:   /login, /pages/2, /items.xml

                           params[:id]                     format

 : Rails Routing from the Outside In. http://guides.rubyonrails.org/routing.html
rails g controller welcome index
spec/controllers/welcome_controller_spec.rb
    # -*- coding: utf-8 -*-
    require 'spec_helper'

    describe WelcomeController do

      describe "#index" do
        it "should be successful" do
          get 'index'
          response.should be_success
        end
        
        it "GET /        " do
          { :get => "/" }.should route_to(
            :controller => "welcome",
            :action => "index" )
        end
      end

    end
bundle exec rspec 
spec/controllers/welcome_controller_spec.rb
config/routes.rb
Rails3dojo::Application.routes.draw do
  # You can have the root of your site routed with "root"
  root :to => "welcome#index"
end



                      WelcomeController#index
 root_path => /
 root_url => http://localhost:3000/
spec/controllers/welcome_controller_spec.rb
    # -*- coding: utf-8 -*-
    require 'spec_helper'

    describe WelcomeController do

      describe "#index" do
        it "should be successful" do
          get 'index'
          response.should be_success
        end
        
        it "GET root_path        " do
          { :get => root_path }.should route_to(
            :controller => "welcome",
            :action => "index" )
        end
      end

    end
http://localhost:3000/
www.getskeleton.com/
http://html2haml.heroku.com/
rm -f app/views/layouts/application.html.erb
git clone git://gist.github.com/1012788.git
mv 1012788/application.html.haml app/views/layouts/
rm -rf 1012788

git clone git://gist.github.com/1012756.git
rm -rf 1012756/.git
mv 1012756 public/stylesheets/sass
http://localhost:3000/
config/routes.rb
Rails3dojo::Application.routes.draw do
  # You can have the root of your site routed with "root"
  root :to => "welcome#index"
  
  resources :pages
end
% rake routes

     root          /(.:format)               {:controller=>"welcome", :action=>"index"}

    pages GET      /pages(.:format)          {:action=>"index", :controller=>"pages"}

            POST   /pages(.:format)          {:action=>"create", :controller=>"pages"}

 new_page GET      /pages/new(.:format)      {:action=>"new", :controller=>"pages"}

edit_page GET      /pages/:id/edit(.:format) {:action=>"edit", :controller=>"pages"}

     page GET      /pages/:id(.:format)      {:action=>"show", :controller=>"pages"}

            PUT    /pages/:id(.:format)      {:action=>"update", :controller=>"pages"}

            DELETE /pages/:id(.:format)      {:action=>"destroy", :controller=>"pages"}
Collection                    Member




            Pages                         Page


index    GET pages_path      show      GET      page_path(id)
new      GET new_page_path   edit      GET      edit_page_path(id)
create   POST pages_path     update    PUT      page_path(id)
                             destroy   DELETE   page_path(id)
rails g controller pages index new
http://localhost:3000/pages
http://localhost:3000/pages/new
spec/controllers/pages_controller_spec.rb
# -*- coding: utf-8 -*-
require 'spec_helper'

describe PagesController do

  describe "#index'" do
    ...
    it "GET pages_path        " do
      { :get => pages_path }.should route_to(:controller => "pages", :action => "index" )
    end
  end

  describe "#new'" do
    ...
    it "GET new_page_path        " do
      { :get => new_page_path }.should route_to(:controller => "pages", :action => "new" )
    end
  end

end
app/views/layouts/application.html.haml
<!doctype html>
...
        %h3 Shortcuts
        %ul
          %li= link_to "Home", root_path
          %li= link_to "Pages", pages_path
          %li= link_to "New Page", new_page_path
http://localhost:3000/
config/routes.rb

Rails3dojo::Application.routes.draw do
  # You can have the root of your site routed with "root"
  root :to => "welcome#index"
  
  resources :pages
  
  namespace "admin" do
    resources :pages
  end
end




        http://localhost:3000/admin/pages
% rake routes
...
    admin_pages GET      /admin/pages(.:format)            {:action=>"index", :controller=>"admin/pages"}
                POST     /admin/pages(.:format)            {:action=>"create", :controller=>"admin/pages"}
 new_admin_page GET      /admin/pages/new(.:format)        {:action=>"new", :controller=>"admin/pages"}
edit_admin_page GET      /admin/pages/:id/edit(.:format)   {:action=>"edit", :controller=>"admin/pages"}
     admin_page GET      /admin/pages/:id(.:format)        {:action=>"show", :controller=>"admin/pages"}
                PUT      /admin/pages/:id(.:format)        {:action=>"update", :controller=>"admin/pages"}
                DELETE   /admin/pages/:id(.:format)        {:action=>"destroy", :controller=>"admin/pages"}




           pages_path                                            admin_pages_path
           edit_page_path(id)                                    edit_admin_page_path(id)
config/routes.rb

Rails3dojo::Application.routes.draw do
  # You can have the root of your site routed with "root"
  root :to => "welcome#index"
  
  resources :pages do
    resources :comments
  end
end




    http://localhost:3000/pages/2/comments
rake routes
...
    page_comments GET      /pages/:page_id/comments(.:format)            {:action=>"index", :controller=>"comments"}
                  POST     /pages/:page_id/comments(.:format)            {:action=>"create", :controller=>"comments"}
 new_page_comment GET      /pages/:page_id/comments/new(.:format)        {:action=>"new", :controller=>"comments"}
edit_page_comment GET      /pages/:page_id/comments/:id/edit(.:format)   {:action=>"edit", :controller=>"comments"}
     page_comment GET      /pages/:page_id/comments/:id(.:format)        {:action=>"show", :controller=>"comments"}
                  PUT      /pages/:page_id/comments/:id(.:format)        {:action=>"update", :controller=>"comments"}
                  DELETE   /pages/:page_id/comments/:id(.:format)        {:action=>"destroy", :controller=>"comments"}




  comments_path                                           page_comments_path(page_id)
  edit_comment_path(id)                                   edit_page_comment_path(page_id, id)
config/routes.rb

Rails3dojo::Application.routes.draw do
  # You can have the root of your site routed with "root"
  root :to => "welcome#index"
  
  resources :pages do
    get 'freeze', :on => :collection
    get 'preview', :on => :member
  end
end



      http://localhost:3000/pages/freeze
      http://localhost:3000/pages/2/preview
rake routes
(in /Users/kato/sandbox/rails3dojo)
        root        /(.:format)                    {:controller=>"welcome", :action=>"index"}
freeze_pages GET    /pages/freeze(.:format)        {:action=>"freeze", :controller=>"pages"}
preview_page GET    /pages/:id/preview(.:format)   {:action=>"preview", :controller=>"pages"}
       pages GET    /pages(.:format)               {:action=>"index", :controller=>"pages"}
             POST   /pages(.:format)               {:action=>"create", :controller=>"pages"}
    new_page GET    /pages/new(.:format)           {:action=>"new", :controller=>"pages"}
   edit_page GET    /pages/:id/edit(.:format)      {:action=>"edit", :controller=>"pages"}
        page GET    /pages/:id(.:format)           {:action=>"show", :controller=>"pages"}
             PUT    /pages/:id(.:format)           {:action=>"update", :controller=>"pages"}
             DELETE /pages/:id(.:format)           {:action=>"destroy", :controller=>"pages"}




                               freeze_pages_path
                               preview_page_path(id)
浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編
浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編
浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編
浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編

Contenu connexe

Tendances

Codeigniter : Custom Routing - Manipulate Uri
Codeigniter : Custom Routing - Manipulate UriCodeigniter : Custom Routing - Manipulate Uri
Codeigniter : Custom Routing - Manipulate UriAbdul Malik Ikhsan
 
Using WordPress as your application stack
Using WordPress as your application stackUsing WordPress as your application stack
Using WordPress as your application stackPaul Bearne
 
REST in practice with Symfony2
REST in practice with Symfony2REST in practice with Symfony2
REST in practice with Symfony2Daniel Londero
 
Synapseindia reviews sharing intro cakephp
Synapseindia reviews sharing intro cakephpSynapseindia reviews sharing intro cakephp
Synapseindia reviews sharing intro cakephpSynapseindiaComplaints
 
Rails 2.3 and Rack - NHRuby Feb 2009
Rails 2.3 and Rack - NHRuby Feb 2009Rails 2.3 and Rack - NHRuby Feb 2009
Rails 2.3 and Rack - NHRuby Feb 2009bturnbull
 
Layouts and Rendering in Rails, Season 2
Layouts and Rendering in Rails, Season 2Layouts and Rendering in Rails, Season 2
Layouts and Rendering in Rails, Season 2RORLAB
 
Binary Studio Academy 2016: Laravel Controllers
Binary Studio Academy 2016: Laravel ControllersBinary Studio Academy 2016: Laravel Controllers
Binary Studio Academy 2016: Laravel ControllersBinary Studio
 
Custom post-framworks
Custom post-framworksCustom post-framworks
Custom post-framworksKiera Howe
 
Chef 0.8, Knife and Amazon EC2
Chef 0.8, Knife and Amazon EC2Chef 0.8, Knife and Amazon EC2
Chef 0.8, Knife and Amazon EC2Robert Berger
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkDirk Haun
 
JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011Arun Gupta
 
Bullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkBullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkVance Lucas
 
Your own (little) gem: building an online business with Ruby
Your own (little) gem: building an online business with RubyYour own (little) gem: building an online business with Ruby
Your own (little) gem: building an online business with RubyLindsay Holmwood
 
Routing System In Symfony 1.2
Routing System In Symfony 1.2Routing System In Symfony 1.2
Routing System In Symfony 1.2Alex Demchenko
 

Tendances (18)

Codeigniter : Custom Routing - Manipulate Uri
Codeigniter : Custom Routing - Manipulate UriCodeigniter : Custom Routing - Manipulate Uri
Codeigniter : Custom Routing - Manipulate Uri
 
Rails 4.0
Rails 4.0Rails 4.0
Rails 4.0
 
Using WordPress as your application stack
Using WordPress as your application stackUsing WordPress as your application stack
Using WordPress as your application stack
 
REST in practice with Symfony2
REST in practice with Symfony2REST in practice with Symfony2
REST in practice with Symfony2
 
Synapseindia reviews sharing intro cakephp
Synapseindia reviews sharing intro cakephpSynapseindia reviews sharing intro cakephp
Synapseindia reviews sharing intro cakephp
 
Rails 2.3 and Rack - NHRuby Feb 2009
Rails 2.3 and Rack - NHRuby Feb 2009Rails 2.3 and Rack - NHRuby Feb 2009
Rails 2.3 and Rack - NHRuby Feb 2009
 
Layouts and Rendering in Rails, Season 2
Layouts and Rendering in Rails, Season 2Layouts and Rendering in Rails, Season 2
Layouts and Rendering in Rails, Season 2
 
Binary Studio Academy 2016: Laravel Controllers
Binary Studio Academy 2016: Laravel ControllersBinary Studio Academy 2016: Laravel Controllers
Binary Studio Academy 2016: Laravel Controllers
 
Custom post-framworks
Custom post-framworksCustom post-framworks
Custom post-framworks
 
Workshop 6: Designer tools
Workshop 6: Designer toolsWorkshop 6: Designer tools
Workshop 6: Designer tools
 
Rails::Engine
Rails::EngineRails::Engine
Rails::Engine
 
Chef 0.8, Knife and Amazon EC2
Chef 0.8, Knife and Amazon EC2Chef 0.8, Knife and Amazon EC2
Chef 0.8, Knife and Amazon EC2
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
实战Ecos
实战Ecos实战Ecos
实战Ecos
 
JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011
 
Bullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkBullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-Framework
 
Your own (little) gem: building an online business with Ruby
Your own (little) gem: building an online business with RubyYour own (little) gem: building an online business with Ruby
Your own (little) gem: building an online business with Ruby
 
Routing System In Symfony 1.2
Routing System In Symfony 1.2Routing System In Symfony 1.2
Routing System In Symfony 1.2
 

Similaire à 浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編

Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)Joao Lucas Santana
 
AngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.jsAngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.jsMark
 
Be happy with Ruby on Rails - CEUNSP Itu
Be happy with Ruby on Rails - CEUNSP ItuBe happy with Ruby on Rails - CEUNSP Itu
Be happy with Ruby on Rails - CEUNSP ItuLucas Renan
 
20120121 rbc rails_routing
20120121 rbc rails_routing20120121 rbc rails_routing
20120121 rbc rails_routingTakeshi AKIMA
 
Angular.js Fundamentals
Angular.js FundamentalsAngular.js Fundamentals
Angular.js FundamentalsMark
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - IntroductionVagmi Mudumbai
 
Rails Routing and URL design
Rails Routing and URL designRails Routing and URL design
Rails Routing and URL designhiq5
 
Node.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash CourseNode.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash CourseAaron Silverman
 
Rails GUI Development with Ext JS
Rails GUI Development with Ext JSRails GUI Development with Ext JS
Rails GUI Development with Ext JSMartin Rehfeld
 
I Phone On Rails
I Phone On RailsI Phone On Rails
I Phone On RailsJohn Wilker
 
Survey of Front End Topics in Rails
Survey of Front End Topics in RailsSurvey of Front End Topics in Rails
Survey of Front End Topics in RailsBenjamin Vandgrift
 
Adventurous Merb
Adventurous MerbAdventurous Merb
Adventurous MerbMatt Todd
 
Build your own_map_by_yourself
Build your own_map_by_yourselfBuild your own_map_by_yourself
Build your own_map_by_yourselfMarc Huang
 
How to replace rails asset pipeline with webpack?
How to replace rails asset pipeline with webpack?How to replace rails asset pipeline with webpack?
How to replace rails asset pipeline with webpack?Tomasz Bak
 

Similaire à 浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編 (20)

Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)
 
AngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.jsAngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.js
 
Merb Router
Merb RouterMerb Router
Merb Router
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
The Rails Way
The Rails WayThe Rails Way
The Rails Way
 
Be happy with Ruby on Rails - CEUNSP Itu
Be happy with Ruby on Rails - CEUNSP ItuBe happy with Ruby on Rails - CEUNSP Itu
Be happy with Ruby on Rails - CEUNSP Itu
 
20120121 rbc rails_routing
20120121 rbc rails_routing20120121 rbc rails_routing
20120121 rbc rails_routing
 
Angular.js Fundamentals
Angular.js FundamentalsAngular.js Fundamentals
Angular.js Fundamentals
 
Rails <form> Chronicle
Rails <form> ChronicleRails <form> Chronicle
Rails <form> Chronicle
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - Introduction
 
Rails Routing and URL design
Rails Routing and URL designRails Routing and URL design
Rails Routing and URL design
 
Node.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash CourseNode.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash Course
 
Rails GUI Development with Ext JS
Rails GUI Development with Ext JSRails GUI Development with Ext JS
Rails GUI Development with Ext JS
 
I Phone On Rails
I Phone On RailsI Phone On Rails
I Phone On Rails
 
Survey of Front End Topics in Rails
Survey of Front End Topics in RailsSurvey of Front End Topics in Rails
Survey of Front End Topics in Rails
 
Adventurous Merb
Adventurous MerbAdventurous Merb
Adventurous Merb
 
Build your own_map_by_yourself
Build your own_map_by_yourselfBuild your own_map_by_yourself
Build your own_map_by_yourself
 
How to replace rails asset pipeline with webpack?
How to replace rails asset pipeline with webpack?How to replace rails asset pipeline with webpack?
How to replace rails asset pipeline with webpack?
 

Plus de Masakuni Kato

Hamackathon ideathon 2014.02.22
Hamackathon ideathon 2014.02.22Hamackathon ideathon 2014.02.22
Hamackathon ideathon 2014.02.22Masakuni Kato
 
RubyMotionでiOS開発
RubyMotionでiOS開発RubyMotionでiOS開発
RubyMotionでiOS開発Masakuni Kato
 
スマートフォンを利用した会員カードシステムサービス「Smaca」のご紹介
スマートフォンを利用した会員カードシステムサービス「Smaca」のご紹介スマートフォンを利用した会員カードシステムサービス「Smaca」のご紹介
スマートフォンを利用した会員カードシステムサービス「Smaca」のご紹介Masakuni Kato
 
スターターライセンスではじめるAtlassian開発
スターターライセンスではじめるAtlassian開発スターターライセンスではじめるAtlassian開発
スターターライセンスではじめるAtlassian開発Masakuni Kato
 
Hamamatsu.rb.20111210
Hamamatsu.rb.20111210Hamamatsu.rb.20111210
Hamamatsu.rb.20111210Masakuni Kato
 
Twitter bootstrap on rails
Twitter bootstrap on railsTwitter bootstrap on rails
Twitter bootstrap on railsMasakuni Kato
 
リーン・スタートアップ のためのテスト
リーン・スタートアップ のためのテストリーン・スタートアップ のためのテスト
リーン・スタートアップ のためのテストMasakuni Kato
 
Start developing Facebook apps in 13 steps
Start developing Facebook apps in 13 stepsStart developing Facebook apps in 13 steps
Start developing Facebook apps in 13 stepsMasakuni Kato
 
CoffeeScript in 5mins
CoffeeScript in 5minsCoffeeScript in 5mins
CoffeeScript in 5minsMasakuni Kato
 
浜松Rails3道場 其の弐 Model編
浜松Rails3道場 其の弐 Model編 浜松Rails3道場 其の弐 Model編
浜松Rails3道場 其の弐 Model編 Masakuni Kato
 

Plus de Masakuni Kato (11)

Hamackathon ideathon 2014.02.22
Hamackathon ideathon 2014.02.22Hamackathon ideathon 2014.02.22
Hamackathon ideathon 2014.02.22
 
RubyMotionでiOS開発
RubyMotionでiOS開発RubyMotionでiOS開発
RubyMotionでiOS開発
 
スマートフォンを利用した会員カードシステムサービス「Smaca」のご紹介
スマートフォンを利用した会員カードシステムサービス「Smaca」のご紹介スマートフォンを利用した会員カードシステムサービス「Smaca」のご紹介
スマートフォンを利用した会員カードシステムサービス「Smaca」のご紹介
 
スターターライセンスではじめるAtlassian開発
スターターライセンスではじめるAtlassian開発スターターライセンスではじめるAtlassian開発
スターターライセンスではじめるAtlassian開発
 
Blogging on jekyll
Blogging on jekyllBlogging on jekyll
Blogging on jekyll
 
Hamamatsu.rb.20111210
Hamamatsu.rb.20111210Hamamatsu.rb.20111210
Hamamatsu.rb.20111210
 
Twitter bootstrap on rails
Twitter bootstrap on railsTwitter bootstrap on rails
Twitter bootstrap on rails
 
リーン・スタートアップ のためのテスト
リーン・スタートアップ のためのテストリーン・スタートアップ のためのテスト
リーン・スタートアップ のためのテスト
 
Start developing Facebook apps in 13 steps
Start developing Facebook apps in 13 stepsStart developing Facebook apps in 13 steps
Start developing Facebook apps in 13 steps
 
CoffeeScript in 5mins
CoffeeScript in 5minsCoffeeScript in 5mins
CoffeeScript in 5mins
 
浜松Rails3道場 其の弐 Model編
浜松Rails3道場 其の弐 Model編 浜松Rails3道場 其の弐 Model編
浜松Rails3道場 其の弐 Model編
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 

Dernier (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 

浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編

  • 2.
  • 5. Version 1.9.2 Version 3.0.7 .rvmrc rvm ruby-1.9.2-p180@rails-3_0_7
  • 6. rails new rails3dojo -m http://railswizard.org/ae25c16f22597ad5ea98.rb -J -T
  • 7. ≠ CSS ≠ Erb
  • 8. Gemfile gem 'rake', '0.8.7' gem uninstall rake -v=0.9.x bundle update ※ Rails3.1 0.9.1 OK!
  • 9. Mac only! cd ~/.pow ln -s /path/to/rails3dojo open http://rails3dojo.dev/
  • 12. HTTP Methods: GET, POST, PUT, DELETE Paths: /login, /pages/2, /items.xml params[:id] format : Rails Routing from the Outside In. http://guides.rubyonrails.org/routing.html
  • 13. rails g controller welcome index
  • 14. spec/controllers/welcome_controller_spec.rb # -*- coding: utf-8 -*- require 'spec_helper' describe WelcomeController do   describe "#index" do     it "should be successful" do       get 'index'       response.should be_success     end          it "GET / " do       { :get => "/" }.should route_to(         :controller => "welcome",         :action => "index" )     end   end end
  • 15. bundle exec rspec spec/controllers/welcome_controller_spec.rb
  • 16. config/routes.rb Rails3dojo::Application.routes.draw do   # You can have the root of your site routed with "root"   root :to => "welcome#index" end WelcomeController#index root_path => / root_url => http://localhost:3000/
  • 17.
  • 18. spec/controllers/welcome_controller_spec.rb # -*- coding: utf-8 -*- require 'spec_helper' describe WelcomeController do   describe "#index" do     it "should be successful" do       get 'index'       response.should be_success     end          it "GET root_path " do       { :get => root_path }.should route_to(         :controller => "welcome",         :action => "index" )     end   end end
  • 22. rm -f app/views/layouts/application.html.erb git clone git://gist.github.com/1012788.git mv 1012788/application.html.haml app/views/layouts/ rm -rf 1012788 git clone git://gist.github.com/1012756.git rm -rf 1012756/.git mv 1012756 public/stylesheets/sass
  • 24. config/routes.rb Rails3dojo::Application.routes.draw do   # You can have the root of your site routed with "root"   root :to => "welcome#index"      resources :pages end
  • 25. % rake routes root /(.:format) {:controller=>"welcome", :action=>"index"} pages GET /pages(.:format) {:action=>"index", :controller=>"pages"} POST /pages(.:format) {:action=>"create", :controller=>"pages"} new_page GET /pages/new(.:format) {:action=>"new", :controller=>"pages"} edit_page GET /pages/:id/edit(.:format) {:action=>"edit", :controller=>"pages"} page GET /pages/:id(.:format) {:action=>"show", :controller=>"pages"} PUT /pages/:id(.:format) {:action=>"update", :controller=>"pages"} DELETE /pages/:id(.:format) {:action=>"destroy", :controller=>"pages"}
  • 26. Collection Member Pages Page index GET pages_path show GET page_path(id) new GET new_page_path edit GET edit_page_path(id) create POST pages_path update PUT page_path(id) destroy DELETE page_path(id)
  • 27. rails g controller pages index new
  • 30. spec/controllers/pages_controller_spec.rb # -*- coding: utf-8 -*- require 'spec_helper' describe PagesController do   describe "#index'" do     ...     it "GET pages_path " do       { :get => pages_path }.should route_to(:controller => "pages", :action => "index" )     end   end   describe "#new'" do     ...     it "GET new_page_path " do       { :get => new_page_path }.should route_to(:controller => "pages", :action => "new" )     end   end end
  • 31. app/views/layouts/application.html.haml <!doctype html> ...         %h3 Shortcuts         %ul           %li= link_to "Home", root_path           %li= link_to "Pages", pages_path           %li= link_to "New Page", new_page_path
  • 33.
  • 34.
  • 35. config/routes.rb Rails3dojo::Application.routes.draw do   # You can have the root of your site routed with "root"   root :to => "welcome#index"      resources :pages      namespace "admin" do     resources :pages   end end http://localhost:3000/admin/pages
  • 36. % rake routes ... admin_pages GET /admin/pages(.:format) {:action=>"index", :controller=>"admin/pages"} POST /admin/pages(.:format) {:action=>"create", :controller=>"admin/pages"} new_admin_page GET /admin/pages/new(.:format) {:action=>"new", :controller=>"admin/pages"} edit_admin_page GET /admin/pages/:id/edit(.:format) {:action=>"edit", :controller=>"admin/pages"} admin_page GET /admin/pages/:id(.:format) {:action=>"show", :controller=>"admin/pages"} PUT /admin/pages/:id(.:format) {:action=>"update", :controller=>"admin/pages"} DELETE /admin/pages/:id(.:format) {:action=>"destroy", :controller=>"admin/pages"} pages_path admin_pages_path edit_page_path(id) edit_admin_page_path(id)
  • 37. config/routes.rb Rails3dojo::Application.routes.draw do   # You can have the root of your site routed with "root"   root :to => "welcome#index"      resources :pages do     resources :comments   end end http://localhost:3000/pages/2/comments
  • 38. rake routes ... page_comments GET /pages/:page_id/comments(.:format) {:action=>"index", :controller=>"comments"} POST /pages/:page_id/comments(.:format) {:action=>"create", :controller=>"comments"} new_page_comment GET /pages/:page_id/comments/new(.:format) {:action=>"new", :controller=>"comments"} edit_page_comment GET /pages/:page_id/comments/:id/edit(.:format) {:action=>"edit", :controller=>"comments"} page_comment GET /pages/:page_id/comments/:id(.:format) {:action=>"show", :controller=>"comments"} PUT /pages/:page_id/comments/:id(.:format) {:action=>"update", :controller=>"comments"} DELETE /pages/:page_id/comments/:id(.:format) {:action=>"destroy", :controller=>"comments"} comments_path page_comments_path(page_id) edit_comment_path(id) edit_page_comment_path(page_id, id)
  • 39. config/routes.rb Rails3dojo::Application.routes.draw do   # You can have the root of your site routed with "root"   root :to => "welcome#index"      resources :pages do     get 'freeze', :on => :collection     get 'preview', :on => :member   end end http://localhost:3000/pages/freeze http://localhost:3000/pages/2/preview
  • 40. rake routes (in /Users/kato/sandbox/rails3dojo) root /(.:format) {:controller=>"welcome", :action=>"index"} freeze_pages GET /pages/freeze(.:format) {:action=>"freeze", :controller=>"pages"} preview_page GET /pages/:id/preview(.:format) {:action=>"preview", :controller=>"pages"} pages GET /pages(.:format) {:action=>"index", :controller=>"pages"} POST /pages(.:format) {:action=>"create", :controller=>"pages"} new_page GET /pages/new(.:format) {:action=>"new", :controller=>"pages"} edit_page GET /pages/:id/edit(.:format) {:action=>"edit", :controller=>"pages"} page GET /pages/:id(.:format) {:action=>"show", :controller=>"pages"} PUT /pages/:id(.:format) {:action=>"update", :controller=>"pages"} DELETE /pages/:id(.:format) {:action=>"destroy", :controller=>"pages"} freeze_pages_path preview_page_path(id)