• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編
 

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

on

  • 2,634 views

2011/6/8 Hamamatsu.rb#4の浜松Rails3道場の資料です。

2011/6/8 Hamamatsu.rb#4の浜松Rails3道場の資料です。

https://github.com/hamamatsu-rb/rails3dojo

Statistics

Views

Total Views
2,634
Views on SlideShare
2,509
Embed Views
125

Actions

Likes
2
Downloads
24
Comments
0

5 Embeds 125

http://d.hatena.ne.jp 94
http://sea-mountain.hatenablog.jp 15
http://s.deeeki.com 9
url_unknown 5
http://www.slideshare.net 2

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道場 其の壱 プロジェクト作成〜Rouging編 浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編 Presentation Transcript

    • RoutingHamamatsurb#4 2011.06.08 @mackato
    • Wiki or CMS 5
    • Routing
    • Version 1.9.2 Version 3.0.7.rvmrcrvm ruby-1.9.2-p180@rails-3_0_7
    • rails new rails3dojo -m http://railswizard.org/ae25c16f22597ad5ea98.rb -J -T
    • ≠ CSS ≠ Erb
    • Gemfilegem rake, 0.8.7 gem uninstall rake -v=0.9.x bundle update ※ Rails3.1 0.9.1 OK!
    • Mac only!cd ~/.powln -s /path/to/rails3dojoopen 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.rbRails3dojo::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.erbgit clone git://gist.github.com/1012788.gitmv 1012788/application.html.haml app/views/layouts/rm -rf 1012788git clone git://gist.github.com/1012756.gitrm -rf 1012756/.gitmv 1012756 public/stylesheets/sass
    • http://localhost:3000/
    • config/routes.rbRails3dojo::Application.routes.draw do  # You can have the root of your site routed with "root"  root :to => "welcome#index"    resources :pagesend
    • % 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 Pageindex 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_helperdescribe 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  endend
    • 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.rbRails3dojo::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  endend 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.rbRails3dojo::Application.routes.draw do  # You can have the root of your site routed with "root"  root :to => "welcome#index"    resources :pages do    resources :comments  endend 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.rbRails3dojo::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  endend 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)