has_many throught and manual handling of updates. Is there something easier ?

Given the model

class Project < ActiveRecord::Base
  has_many :assignments
  has_many :assignees, :class_name => "User", :through => :assignments,
:source => :user

class User < ActiveRecord::Base
  has_many :assignments;

class Assignment < ActiveRecord::Base
  belongs_to :project
  belongs_to :user

I am currently updating the project assignees in my

I first tried to do something like

@project.assignees = User.find(params[:assignee_ids])

but this fails as rails cannot know how to initialize my assignments. I
wish it could!

I've read

So I am updating my table doing something like:

  def update
    @project = Project.find(params[:id])
    @users = User.find(:all)
    if request.get?
      render :action => 'edit'
      if params[:assignee_ids]
        # FIXME can't this be railsified somehow ?? this is ugly...
        new_assignees = User.find(params[:assignee_ids])
        # remove old ones...
        @project.assignees.each do |old_assignee|
          if ! new_assignees.include? old_assignee
            Assignment.delete_all("user_id = #{old_assignee.id} and
project_id = #{@project.id}")
        # add the new ones
        new_assignees.each do |new_assignee|
          # remove those who are not present anymore
          if ! @project.assignments.include? new_assignee
            @project.assignments.create!(:user => new_assignee)
        # this won't work because I don't have an id column...
        # @project.assignments.clear
        Assignment.delete_all("project_id = #{@project.id}")
      if @project.update_attributes(params[:project])
        flash[:notice] = 'Project was successfully updated.'
        redirect_to :action => 'edit', :id => @project
        render :action => 'edit'

Is there something simpler/cleaner ?