SlideShare una empresa de Scribd logo
1 de 44
Descargar para leer sin conexión
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編

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Similar a 浜松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
 

Similar a 浜松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?
 

Más 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
 

Más 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編
 

Último

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
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
 

Último (20)

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
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
 

浜松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)