Bathakarai
Bathakarai

Reputation: 1537

rails object expected got string in Rails 3

class Result < ActiveRecord::Base
  has_one :p1, :class_name => "Player", :foreign_key => 'player_id', :validate => true
end

When i try to create a new record by using Result.new it throws Result(#203425120) expected, got String(#127815260).

I seen most of the related questions..But they given only select sql based. Not creating new records.. Any comments would be appreciated..

Upvotes: 1

Views: 656

Answers (1)

sjain
sjain

Reputation: 23344

Probably you have p1_id in the database instead of just p1.

So, When you are referring to players, you should use the

<%= f.collection_select :p1_id, Player.all, :id, :name %>

Referred from:

rails object expected got string

Upvotes: 1

Related Questions