Enum? polymorphic?

hi

I have two tables namely, liquids and unit,

in unit there is :name,:string which store various unit, e.g. L mL Sv
mm

in liquids, there are
:liquidA, :integer
:liquidAunit, :string
:liquidB, :integer
:liquidBunit, :string

how should I define the relation between the two table, so that
liquid will display the unit name of A and B respectively

Can a liquid have more than one unit?

if not it is simple

liquid belongs_to :unit
with a unit_id in the table, instead of the :liquidAunit, :string

in a liquid table , there are many liquid and each liquid has one
unit.

Great!

Can you please paste your association? I would like to see how you
solved it
and make sure I understood your initial requirement.

regards
Ivor

Thank you Paul.
I have achieve what I want by following
http://ruby.about.com/b/a/000069.htm

I have followed exactly the example in
http://ruby.about.com/b/a/000069.htm

And I am using Activescaffold.

The field has been reconfig as follow

class CustomerController < ApplicationController
active_scaffold :customer do |config|
config.columns[:billing_address].ui_type = :select
config.columns[:shipping_address].ui_type = :select
end

 layout 'activescaffold'

end

So in my real implementation,
Customer => liquid
Address => unit

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