Sendagaya.rbの#14を開催しました。RailsにおけるRESTfulなURL設計勉強会の復習を踏まえ、config/routes.rb を持ち寄り具体的なリソース設計についてみんなで相談し合いました。
場所は、株式会社コネクトスターです。いつもお世話になっております。
私の見せた config/routes.rb は、こんな感じ。RESTの勉強会の内容を踏まえて、大分理想的な感じになって来ました。
resources :users, :only => [:show] do
resources :followings, :only => [:index]
resources :followers, :only => [:index]
resources :groups, :only => [:index]
end
resources :posts do
resources :comments, :only => [:index, :new, :create, :destroy]
resources :likes, :only => [:index, :create, :destroy]
resources :increments, :only => [:index, :create, :destroy]
end
resources :groups do
resources :posts, :only => [:index, :new]
end
# /my scope for current_user
scope :path => :my do
resources :followings, :only => [:index, :update, :destroy], :as => :my_followings
resources :followers, :only => [:index], :as => :my_followers
resources :feeds, :only => [:index], :as => :my_feeds
resources :groups, :only => [:index], :as => :my_groups
resources :memberships, :only => [:index, :update, :destroy], :as => :my_memberships
delete '' => 'users#destroy'
root :to => 'users#show', :as => :my_root
end
get 'about' => 'pages#about', :as => :about
get 'terms' => 'pages#terms', :as => :terms
get 'policy' => 'pages#policy', :as => :policy
get 'login' => 'pages#login', :as => :new_user_session
root :to => 'pages#index'
my リソースは、一般ユーザーと別の見せ方をする場合はコントローラ自体を分けてしまうのもよさそうです。
他にも、こんなお話(リンク先はtogetter)がありました。
今回はプロジェクターとホワイトボードのコンボが良かったです。プロジェクターでホワイトボードな壁に映した画面に解説書けるのが良かったです。今月はRESTfulシリーズな会となってますが、来週月曜日はお休みの予定。RailsにおけるRESTfulなURL設計勉強会 vol.2(仮)の告知もそろそろ出来ると思います。