All threads / Controller naming...

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Controller naming...

Alan Reid asked in Rails

Evening all,
So i have a question about naming controllers. Which would be best to use? MyOrder or MyOrders

Is it just the DB which get pluralised?

It's convention to use the plural form for your controllers.

Example:
OrdersController -> app/controllers/orders_controller.rb, a model would be Order

If you think about it, when you define a route you most likely use resources :orders in that circumstance. Then Rails knows it's looking for an orders controller.

I hope that helps?

Cheers Andrew,
Orders makes much more sense :D thanks

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 37,106+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.