Finding with composite_primary_keys

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 end

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 {:method=>:get}

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.



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)


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.