Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTracy Mason
Courses Plus Student 2,446 PointsStatus/statuses?
This may seem like a simple question, but ... why does rails create a project file in the models folder called "status.rb" but if you look at the actual files created, they are called "status*es*"? And then when you want to check out the application, you type status*es*, but when we created it we created using "generate scaffold status ..." Does Rails just know that more than one entry will be included in the status updates?
1 Answer
Maciej Czuchnowski
36,441 PointsThere are some specific conventions in Rails when it comes to singular and plural forms. You will get used to it. I didn't get it at first at all. In general, when you are referring to the model (and usually using the capital letter), you use singular form. And in most other places, you use the plural form. Singular is also conventionally used when you are sure you will refer to the single element (for example, when naming the instance variable in show action).
Tracy Mason
Courses Plus Student 2,446 PointsTracy Mason
Courses Plus Student 2,446 Pointsok. So when my files were created, for instance, a file called "test/functional/statuses_controller_test.rb". How did it know to change status to statuses when rails created it? I'd originally created it using "rails generate scaffold status name:string content:text.
Maciej Czuchnowski
36,441 PointsMaciej Czuchnowski
36,441 PointsRails has a built-in system that pluralizes words correctly (even irregular ones, like 'child'). It does it when generating stuff and you also have a
pluralize
method that you can use in your views that will display the word given as a second argument as singular or plural, depending on a number that it gets as the first argument. Yes, Rails has some magic in it :). http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-pluralizeTracy Mason
Courses Plus Student 2,446 PointsTracy Mason
Courses Plus Student 2,446 PointsThank you! I thought maybe I was going crazy there for a minute!