Skip to content

Latest commit

 

History

History
90 lines (73 loc) · 3.34 KB

2nd_20161205.md

File metadata and controls

90 lines (73 loc) · 3.34 KB

Step-to-Rails-Expert.rb 第二回

本日の流れ

  • 自己紹介
    • お名前
    • 普段の触っている分野
    • 本日やること・話したいこと
  • 作業・お話
  • 今日の成果
    • やったこと
    • 次回のテーマリクエスト・感想等(あれば)

参加者のお名前(時計回り)

当日の話題

routes.rb どう書く?

  • リソースをネストする際どう書く?
  • shallowオプション
  • ルーティング設計、大事ですよね
    • /:username をユーザページのURLに使うと、 /faq とか /login とか取られちゃう)
      • あらかじめ使いそうなのを全部予約する
      • Twitterとかは /i/:username/hoge とかを併用してる
      • /@:username にする
scope path: :'@:user_name', constraints: { user_name: // } do
  root to: 'users#show', as: :user
  resources :followings, only: [:index, :create, :destroy]
end
/products/new

GET /shops/:shop_code # => ShopsController#show
GET /shops/:shop_code/:code # => Shops::ProductsController#show
GET /shops/:shop_code/:code/edit # => Shops::ProductsController#edit
POST /shops/:show_code/:code/previews # => Products::PreviewsController#create


/shops/:shop_code/edit # => ShopsController#edit
/shops/:shop_code/profile # => Shops::ProfilesController#edit
/shops/:shop_code/password # => Shops::PasswordsController#edit
/shops/:shop_code/notification # => Shops::NotificationsController#edit

/products/:shop_code # => ProductsController#index
/products/:shop_code/:code # => ProductController#show
/products/:shop_code/:code/edit # => ProductController#edit
/products/:shop_code/:product_code/preview # => Products::PreviewsController#show
resources :shops, path: '/products/', param: :code, only: [] do
  resources :products, param: :code, path: '/', except: [:new, :create, :edit] do
    scope module: :products do
      resource :preview, only: [:show]
    end
  end
end
  • gitlabは上記のようなルーティングをしている。redmineはget or postメソッドを使っている場合がある

  • railsに乗っているのではあれば、既存メソッドを使用し、可読性が損なわれるような時は諦めて#get#postを使う。

Resource Routingつらくね? - Qiita http://qiita.com/r7kamura/items/dea3c58b6fc81142a363

電話決済サービス

電話利用のシンプル決済から店舗行列受付システムまで、TC Tokyoハッカソン優秀作をご紹介 | TechCrunch Japan http://jp.techcrunch.com/2015/12/11/techcrunch-tokyo-hackathon-2/

decorator層でどこまでやるのかな? @tomato360

decoratorでhtmlを出力するコードを書いて良いものか? 一つのカラムに保存している文書の1行目をタイトルとして表示したい。他は普通のMarkdown的な表示をしたい。(時間も差し迫っているのだ書くだけ・・・ このURLを見るとむしろHTMLをがりがりコードで書いてもいいものなのかな? http://ruby-rails.hatenadiary.com/entry/20150415/1429031791

懇親会

近くのルノアールでまったり実施します。