Login and related data

I have a login with a model of “users”, which I’ve been able to get
working, with one field being “company”. This is a main user who can add
groups, so other group-users can login separately. In the groups table I
have a user_id so I know the connection. When I have a login form for
groups where I’ve added three fields; company, username and password.
What I don’t know is how I define the company field? Is this right?

<%= text_field “group”, “user.company” %>

<label for="group_username">Login</label>
<%= text_field "group", "username" %><br/>

<label for="group_password">Password</label>
<%= password_field "group", "password" %><br/>

How do I refere to in the login action and authenticate? And when doing
a validate with validates_presence_of?

Pål Bergström wrote:

<%= text_field “group”, “user.company” %>

No, you can’t do this. Instead, set @user = @group.user
in your controller, code the field as

  <%= text_field :user, :company %>

and deal with both params[:user] and params[:group] in
your controller. Exactly what you do depends on the
new/existing status of both the group and user records.

We develop, watch us RoR, in numbers too big to ignore.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs