| Start |
|---|
| Controllers Controller class names are pluralized. The reason is the controller controls multiple instances of object instance. For Example: For Example: If the controller class name has multiple capitalized words, the table name is assumed to have underscores between these words. For Example: If a controller is named |
| Models The model is named using the class naming convention of unbroken MixedCase and is always the singular of the table name. For Example: If a table was named For Example: If a table was named Rails will then look for the class definition in a file called If the model class name has multiple capitalized words, the table name is assumed to have underscores between these words. For Example: If a model is named |
| Filenames and autoloading Rails files - and Ruby files in general - should be named with is the file that contains the Consistent naming is important since Rails makes use of auto-loading files as needed, and uses "inflection" to transform between different naming styles, such as transforming E.g. if Rails sees that the It is therefore also important to name files for what they contain, since the autoloader expects file names to match content. If, for instance, the If you add a dir under
One more thing to pay attention to (especially if English is not your first language) is the fact that Rails accounts for irregular plural nouns in English. So if you have model named "Foot" the corresponding controller needs to be called "FeetController" rather than "FootsController" if you want rails "magic" routing (and many more such features) to work. |
| Views and Layouts When a controller action is rendered, Rails will attempt to find a matching layout and view based on the name of the controller. Views and layouts are placed in the Given a request to the
|
| Models class from Controller name You can get a Model class from a Controller name this way (context is Controller class): |
Read Article
https://develop.horje.com/learn/1434/reference