Cross linking controllers & polyporhism

Alright, so this problem is two fold. One probably has a simple

And the other probably has a simple answer…

Maybe not.

  1. I have many different controllers… three of note would be
    ‘order’, ‘review’ & ‘quote’.

if im in viewing “/orders/list” i would like to generate a link to go
to the corresponding review & quote.

can a generic link_to be somehow cajoled into going to “/reviews/show/
23432” where 23432 is the review_id of the order?

problem 2) i can think of a million and one kludgy ways to do this but
none of them seem to be good rails form…

the same app has a model for inspection sheets. each order is assigned
an inspection sheet and each inspection sheet has multiple validated
fields which are created by whoever approves the order… for
example… (and believe me, this is a gross oversimplification)

order #23432 is for a custom made, standard square box.

the boxes will be made by hand and each operator is going to check for
4 things.

length, width and height of the box, limits specified at order time
visual inspection

heres where i think polymorphism might be a good solution, just dont
know how to properly implement it…

the length width and height are all numbers with a given range. when
the inspected boxes are out of that range i’ll raise some kind of
error or something…

the visual inspection (and many other types of fields) are booleans…
go/no go… good/no good… etc…

my original scheme went something like this…

inspection_sheets: table containing all sheet_id’s and their
corresponding orders.

inspection_sheet_fields: a table to hold all the definition fields as
users create them for new inspection sheets… it would have a
sheet_id, field_name…eg “length”, and in the case of numerical
input… a max_value and a min_value… or in the case of booleans…
just a good_value…


inspection_sheet_rows: a table which would contain a sheet_id,
field_id and a “measured_value” or some such… to hold the physical
value measured.

now if you ask me, that last table, especially that last table - will
get filled up in quite a hurry… but thats another bridge to cross at
another time… not to mention the cost of re-evaluating the entire
insepction sheet every time someone one wants to do “inspection_sheets/

im just looking for some suggestion on how to do this rubily…

thanks for the input.

  1. link_to :controller => “order”, :action => “show”, :id => (or whatever the id is)

  2. Im confused about re-evaluating everytime someone show’s, evaluate
    on save, not on view? Also, on the validations. You may find this

Zach I.
→ Blog –
→ Company –
→ Portfolio –

Thanks for the help Zach,
It occurred to me about 3 seconds after I posted it that :controller
=> was the one thing I didn’t try… Heh, I knew it had to be easy.

And those additions to validates_numerically_of are certainly helpful.
Now the fun part seems like figuring out how to store each fields
necessary type of VNO and recalling it. It’s gonna be a long week.

Here’s a question for you. The relationship between each fields
“definition” field and its corresponding inspection field… would you
say that the definition field HABTM inspections or just that each
inspection has_one definition?

Is there a large difference?