After being frustrated (yet again) last week when attempting to use
the salted_login_generator in a new rails project, I have modified it
so that it works better for my needs. Since the
SaltedHashLoginGenerator wiki page seems to indicate many people are
frustrated by this package (which is very nice but has been broken
since rails 1.1.4 I think) I have gem-ified my version of the
generator and released it. In my version:
* All of the tests pass on Rails 1.1.[456].
* Example DB schema uses migrations.
* The first_name, last_name attributes have underscores.
* Includes a quick start zip of preconfigured default rails app
files.
* The README_USER_LOGIN tells you everything you need to know.
It is available at
http://akuaku.org/code/login_sugar_generator-0.9.1.gem
This was my first time looking at the internals of generators and
gems, but I think I got it mostly right. It seems to work in fresh
rails projects in my tests. It's probably brittle in terms of naming
the controllers though, so you may have to make some adjustments if
you use something other than User and Localization as your controller
names.
I realize Deirdre Saoirse Moen has taken over the salted login project
and a fixed version 1.1.2 will probably be out soon, so just consider
this a measure of temporary sanity.
Updated on September 6: Making a last minute change before releasing and running off to Burning Man for a week is never a good idea is it? Version 0.9.1 released to fix the missing last_name references. Thanks BobF!









Works well, although if you haven't ever installed the localization stuff you may have a few things to work through on Windows (see http://wiki.rubyonrails.com/rails/pages/iconv/ for details).
I also had to fix one thing when using the 0.9.0 version of this: almost every spot in the files where "first_name" is used turns out to have two references to "first_name" and none to "last_name". Key ones include migration_login_sugar.rb, _edit.rhtml, user_controller.rb, user_notify.rb (multiple times).
Posted by: BobF | 2006.09.02 at 11:47 AM
I'm trying to use this under Rails 1.1.2. I had to change the name of the migration class from "LoginSugar" to "MigrationLoginSugar". I got one error in the functional tests (test_delete) and
and two failures (test_forgot_password, test_signup). These failures were similar to the ones in the original SHLG; setting use_instantiated_fixtures in test_helper.rb didn't help. I was unable to signup until I fixed lib/clock.rb (at() and now() were defined as instance methods, but called as class methods in models/user.rb). Then I was able to signup and confirm, but my session disappeared when I navigated off the welcome page, and subsequent logins are unsuccessful.
In short: not confidence-inspiring. It's frustrating, as the features are just what I need. I'm going to go the acts_as_authenticated route, which is more labor-intensive, but at least I'll understand how it works at every step of the way.
Posted by: Roger | 2006.09.22 at 01:59 AM
Roger, lines 76-79 or the README explain what you have to do with the migration script:
"This model is meant as an example and you should extend it. Rename it to db/migrate/###_login_sugar.rb where ### is the
proper new migration level. If this is your first migration for this rails project, use 001."
This is not supported under Rails 1.1.2, as stated in the announcement "All of the tests pass on Rails 1.1.[4-6]".
To be more clear, it it is only tested for rails 1.1.4 and up.
I'm not sure if that is why your tests were failing or not, but I would suspect so.
Posted by: dav | 2006.09.25 at 09:45 PM