All threads / Rails for Beginners Part 13: Creating a Sign Up Form Discussion

Ask A Question


You’re not receiving notifications from this thread.

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.

Join the discussion

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

Join 48,387+ 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

    © 2021 GoRails, LLC. All rights reserved.