Rails for Beginners Part 13: Creating a Sign Up Form Discussion
Plural/singular confuses me. I know Models are singular ("User"). Why "Registrations" (plural) for the controller? Does it matter for controllers which aren't directly associated with a Model? Looking at your source, I see many of the views are plural also. Any tips for keeping this straight?
Here are few naming conventions on models, controllers, views, routes
Usually models are singular and controllers plural. A User model has features, validations etc which define a user. A UsersController handles/controls all users.
However, in case of controllers and views they take singular names when they are not associated with models or do not abstract a resource e.g WelcomeController.
I think with practice this naming will come intuitively.
Could you clarify why "model: @user" instead of "model: User"? Why the instance variable instead of the Model name? Thank you.
AFAIK, that's because you need to pass an instance of a class not the class. So that, the form will fill out the missing parts of that specific instance upon submission of the form and save into the DB.
Thank you. That helps a little I guess. :-) So a generic instance of the class has been created as a Ruby object with no specific properties via the "new" method, and then "create" inserts the user's values and attempts to save it? Still hasn't clicked in but I guess it makes sense the more you do it.