Forum: Ruby on Rails Finding with composite_primary_keys

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Philip N. (Guest)
on 2007-02-23 23:33
(Received via mailing list)
I've used composite_primary_keys to define a legacy table in my
application -

class AircraftHistory < ActiveRecord::Base
  def self.table_name() "t1010aircraft_history" end

  set_primary_keys :aircraft_id, :aircraft_sequence

  belongs_to :aircraft

I've generated the controller and views using -

script/generate scaffold aircraft_history

The "list" functionality works fine, but when I click on "show" or
"edit" I
get the error message -

no route found to match "/aircraft_history/show/35707,4" with

The "35704,4" are the values for "aircraft_id,aircraft_sequence"

How to I make it able to use the combined value.   I see an explanation
on the
web page about using to_s or to_param, but I'm not sure exactly how.


Luke I. (Guest)
on 2007-02-23 23:38
(Received via mailing list)
In your routes.rb file, you should put the following:
map.connect ':controller/:action/:aircraft_id,:aircraft_sequence'

I'm fairly certain that will work (I'm moderately newbie-ish)
Philip N. (Guest)
on 2007-02-24 00:20
(Received via mailing list)

Thanks for the tip. � I will give it a try.

I had thought that I could pass the multiple parameters into the
controller as
a single parameter, but was obviously looking in the wrong place.

This topic is locked and can not be replied to.