author avatar

syedsibtain

Wed Jul 31 2024

Namespaces in Rails help organize our application by grouping related controllers, models, and views into separate directories. Using namespaces with scaffolding keeps our codebase structured and manageable, especially in larger applications.

Example.
rails generate scaffold Order::PurchaseOrder order_number:string business_unit:string ...

This will create files under the Order namespace, including controllers, models, and views. This approach keeps our codebase structured, with Order as a namespace, making it easier to manage related components and maintain clarity in larger applications.



app/
├── controllers/
│   └── order/
│       └── purchase_orders_controller.rb
├── models/
│   └── order/
│       └── purchase_order.rb
├── views/
│   └── order/
│       └── purchase_orders/
│           ├── _form.html.erb
│           ├── edit.html.erb
│           ├── index.html.erb
│           ├── new.html.erb
│  


#rails #namespace