Essentail Rails Design Pattern

Write Good Rails Code

CRUD-Like Action

場景

#TODO

Bad Smell

1
2
3
4
5
6
7
8
9
class UsersController < ApplicationController
  def add_friend
    # ....
  end

  def add_to_favorites
    # ....
  end
end

GOOD SMELL

1
2
3
4
5
6
7
8
9
10
11
class User::FriendsController < ApplicationController
  def create
    # ...
  end
end

class User::FavoritesController < ApplicationController
  def create
    # ...
  end
end

Comments