Gary Huntress wrote:
> I have to manage some data for each member of a local
> organization. Very basic stuff, name/addr/email/phone and a few
> dates. Naturally they should only edit their own record and this
> assumes a user/pass. I added the login via login generator and it
> works great. I had planned to have a memberships table that held
> a record for each user, along with the users table that the login
> generator requires.
>
> To do this would mean that when a new user is added by the login
> generator that an empty record would have to be created in the
> memberships table at the same time. I''m sad to say that at this
> time even that simple a task is over my head.
>
> In the login generator it said that they encourage extending the
> users record beyond id/name/password and it seems that it would
> make sense for me to do that in this case. Basically, I want to do
> 2 things, 1) continue using the login generator code because it
> works fine and 2) extend the User model to include my new fields
> and to generate scaffolding based on that that I will then modify
> (hopefully) to force users to edit only their own record.
>
> To do this I think I need to generate a second model that is based
> on the user table. Is that possible? I have not found a simple
> way to do that yet.
I think you''re over-thinking it. I''ve extended the login
generator
many times by doing the following:
- adding the new columns to the users table as need (name, address,
country, phone, whatever)
- editing the login and signup views to cater for the new fields
- creating a new action for the LoginController called "profile"
which allows the logged in user to edit/save their own login details
Tobias'' code is just a nice basic foundation which you take and
extend to suit your needs. Unless you have two classes that need to
inherit or belong to the User class (example, I have a site with both
Members and Businesses that need to login, so they both belong to
User), I think it''s much easier to take what the Login generator
created, and tweak it to suit your needs.
Regards,
Justin French
----------------
JustinFrench.com
TextDrive.com
Strongspace.com
Indent.com.au