Forum: Ruby on Rails struggling with relatively simple out of model updating

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Craig White (Guest)
on 2006-06-13 00:19
(Received via mailing list)
I'm trying to do a In/Out thing...

In my in_outs_controller.rb

  def edit_in_out
    @in_out = InOut.new
    @in_out.user_id = params[:id]
    @user = User.find_by_id(@in_out.user_id)
    if @in_out.save
      @user.update_attribute(:in_out, params[:user][:in_out])
      flash[:notice] = 'In/Out was successfully updated.'
      redirect_to :action => 'list'
    else
      render :action => 'edit_io'
    end
  end

The error I get is...
ActiveRecord::AssociationTypeMismatch
InOut expected, got String

Request
Parameters: {"user"=>{"will_return"=>"", "in_out"=>"In"}, "commit"=>"
Save ", "id"=>"19"}

Users table has
    add_column :users, :in_out, :string, :limit => 3
    add_column :users, :will_return, :string, :limit => 48

How can I do this?

Craig
This topic is locked and can not be replied to.