1

I have a link table which looks like this:

create_table "links", :id => false, :force => true do |t|
  t.integer model1_id
  t.integer model2_id
  t.string someotherinfo
end

I'm currently defining routes like this:

match '/links/:model1_id/:model2_id/' => buggable_links#validate

It seems like I ought to be able to do something more like resources rather than writing out all the match statements. What's the right way of having rails generate resource routes on models which do not have a single primary key, such that URLs contain two IDs?

N.B. I'm aware that one possible answer is 'just add an autoincrementing pk'. The pros and cons of that are discussed in this question, but for the purposes of this question let's assume I want to leave my DB schema as it is.

Community
  • 1
  • 1
kdt
  • 27,905
  • 33
  • 92
  • 139

1 Answers1

0

This is the correct way to do it.

The only thing you should add is in the resources of buggable_links add the validate function as a get method.

Nachshon Schwartz
  • 15,289
  • 20
  • 59
  • 98