Hey guys I'm having a little trouble what I think should be a pretty
simple relationship between tables.

Player.rating is a f-key to Rating.id, both fields are integers

When I try to add a new player I get this error message

ActiveRecord::AssociationTypeMismatch in PlayersController#create
Rating(#38968656) expected, got String(#19165136)

In my form I have this for the rating dropdown
f.select :rating, options_for_select(Rating.all.map { |r| [r.level,
r.id] })

In my models I have

#player
has_one :rating

#rating
belongs_to :player, :foreign_key => "id"

The controller is pretty straight forward
  def create
    @player = Player.new(params[:player])
    respond_to do |format|
      if @player.save
        flash[:notice] = "Registration Successful"
        format.html { redirect_to root_url }
      else
        flash[:notice] = "Error in registration"
        format.html { render :action => "new" }
      end
    end
  end

Any guidance?
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to