Is there any official documentation for the Rails 8 Authentication generator?
The only “doc” I found that in the Rails 8 blog post announcement:
Just run
bin/rails generate authentication
and you’ll get basic models forSession
andUser
, together with aPasswordsMailer
,SessionsController
, and anAuthentication
concern. All you have to bring yourself is a user sign-up flow (since those are usually bespoke to each application). No need to fear rolling your own authentication setup with these basics provided…
I would be nice to have something to introduce it as a starter authentication, and maybe even explain some of the choices, before pushing you out of the nest to make it your own.
There are some docs:
-
All generators have help docs (
rails g authentication --help
), but this one is pretty sparse. -
There is a generators guide (covers
--help
): Creating and Customizing Rails Generators & Templates — Ruby on Rails Guides -
I’ve found the source code to be very readable (but without any explainer comments):
This feels really strange. I don’t think I’ve ever come across a web dev framework that doesn’t have a “Docs” link on the official site. The “Guides” are excellent but they don’t provide full coverage.
Rails does too, just not called “Docs”. The API link on the homepage is that “full coverage” framework documentation. They’re very good and cover every (public) Rails method, including those used within the generator templates.
But this generator…weeell , this is a brand new generator, so the --help
docs will probably get a small update as folks like yourself dig in, ask questions, learn, and submit PRs to cover the gap.
P.S. If you’re looking for something, I’ve started watching some GoRails videos on it (Rails 7.1 Authentication From Scratch, etc.), and comparing with the authentication-zero generators.
Good tips. Thank you!
Hey there. I found this article written by Jaimy Simon. It explains most of the actors and has a couple of diagrams to get your head around the flow.
Also, as @ansonhoyt mentioned, the API reference contains valuable information about the methods used on the generated concerns/code, mainly has_secure_password and authenticate_by
Oh thanks – this is very helpful.