Assigning user's session ID to a sub-table

Hi.

I’m using LoginEngine to manage session info.

On this site, I’d like users to be able to create groups, and then allow
other users to sign up. The approach I’m taking is putting a “join” link
on the “show” page for a group, and then adding the user as a member in
the Group controller. There is a sub-table for groups called “members”
(belongs_to groups). What I’m trying to do is assign the session id to
the members table so that the user who clicks “Join” is added to the
list of members.

The join code (from Group controller) is roughly as follows:

  @group = Group.find(@params[:id])
  @group.members.create(params[:member])
  • @group.members.user = @session[‘user’]
    @groups.members(params[:member]).joined = 1
    flash[:notice] = ‘You have successfully joined @group.title
    redirect_to :action => ‘show’, :id => @group

The problem is with the starred line: for some reason it won’t add the
user ID to the members row. The current error is:

undefined method `user=’ for Member:Class

Thoughts?

Thanks a lot,

  • Raffi.

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