/api/v1/dashboards • GET /api/v1/dashboards/1 • PUT /api/v1/dashboards/1 • POST api/v1/dashboards/1/lists • PUT api/v1/dashboards/1/lists/1 • GET api/v1/dashboards/1/lists/1/cards • POST api/v1/dashboards/1/lists/1/cards • PUT api/v1/dashboards/1/lists/1/cards/5 • POST api/v1/dashboards/1/lists/1/cards/4/move
command • rails g model Dashboard title:string user:references • Update the Dashboard Model to create the associations • belongs_to :user • has_many :lists, ->{ order(sort_order: :asc) }
command • rails g model List title:string sort_order:integer dashboard:references • Update the List Model to create the associations • belongs_to :dashboard • has_many :cards, ->{ order(sort_order: :asc) }
command • rails g model Card title:string description:text sort_order:integer list:references • To add the assignee as the user, edit the migration file with the following content • t.references :assignee, foreign_key: { to_table: :users } • Update the Card Model to create the associations • belongs_to :list • belongs_to :assignee, class_name: "User", optional: true
:users, only: [:index] resources :dashboards, only: [:index, :show, :create, :update] do resources :lists, only: [:create, :update] do resources :cards, only: [:index, :show, :create, :update] do member do put 'move’ end end end end end end
Dashboard • Update the generated class class DashboardSerializer < ActiveModel::Serializer attributes :id, :title has_many :lists, serializer: ListSerializer end
List • Update the generated class class ListSerializer < ActiveModel::Serializer attributes :id, :title, :sort_order has_many :cards, serializer: CardSerializer end
Card • Update the generated class class CardSerializer < ActiveModel::Serializer attributes :id, :title, :description, :sort_order, :assignee def assignee object.assignee&.email end end