Last active
January 25, 2023 18:31
-
-
Save andrewhao/d9bf84a77774d8eba639f12fbaad5c29 to your computer and use it in GitHub Desktop.
Domain-oriented Rails file structures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Ridesharing | |
class DriverController | |
append_view_path(‘app/domains’) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Before | |
module Ridesharing | |
class Vehicle | |
belongs_to :driver | |
end | |
end | |
# After: | |
module Ridesharing | |
class Vehicle | |
belongs_to :driver, class_name: "Ridesharing::Driver" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app/ | |
domains/ | |
ridesharing/ | |
driver.rb | |
driver_controller.rb | |
drivers/ | |
show.html.haml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app/ | |
domains/ | |
ridesharing/ | |
vehicle.rb | |
vehicles_controller.rb | |
trip.rb | |
service_tier.rb | |
trip_price.rb | |
... | |
marketing/ | |
campaign.rb | |
campaigns_controller.rb | |
contact.rb | |
... | |
customer_support/ | |
issue.rb | |
issues_controller.rb | |
... | |
identity/ | |
user.rb | |
users_controller.rb | |
role.rb | |
session.rb | |
... | |
ecommerce/ | |
payment.rb | |
payments_controller.rb | |
charge.rb | |
invoice.rb | |
pricing_tier.rb | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Before: | |
class Driver < ActiveRecord::Base | |
end | |
# After: | |
module Ridesharing | |
class Driver < ActiveRecord::Base | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app/ | |
models/ | |
driver.rb | |
controllers/ | |
driver_controller.rb | |
views/ | |
drivers/ | |
show.html.haml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment