How update a record which hasn't id column?

Hi, I’ve two database tables 1-N related and one of them doesn’t have id

matches (id, more columns), match_details(match_id, … more columns)

Also have two models that represents these tables:

Match MatchDetail
has_one :match_detail belongs_to :match,
:foreign_key => ‘match_id’

When I create a Match object with a new MatchDetail object related to
everything works fine, but when I try to update some MatchDetail
I get an update error from DB:

@match =
@match.match_detail =

@match = Match.find(params[:id]) <-------- THIS METHOD MODIFIY SOME VALUES OF match_detail

Mysql::Error: Unknown column ‘id’ in ‘where clause’: UPDATE
match_details SET
home_goals = 2, match_id = 1, away_goals = 0 WHERE id = NULL

id doesn’t exist because the migration for this table specified not id

create_table :match_details, :id => false do |t|
  t.column :match_id, :integer, :null => false
  t.column :home_goals, :integer, :default => 0
  t.column :away_goals, :integer, :default => 0

I also have try to declare match_id column as primary key, but doesn’t
it raises the same error.
What I forgot to do?

As almost always I answer to myself. I didn’t find the solution,
but I have cerate match_details table with an id, it easier and I don’t
wanna waste time and effort to solve that problem.

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