Ok I have a many to many relationship with additional fields on the join
table. I'm joining Materials and Locations via LocationMaterial.
class Location < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
name :string
timestamps
end
set_default_order "name DESC"
belongs_to :space
has_many :location_materials, :dependent => :destroy, :accessible => :true
has_many :materials, :through => :location_materials
children :materials
...
end
class Material < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
name :string
quantity :float
timestamps
end
set_default_order "name DESC"
has_many :location_materials, :dependent => :destroy
has_many :locations, :through => :location_materials, :accessible => :true
...
end
class LocationMaterial < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
condition enum_string(:Intact, :Damaged, :SeverelyDamaged)
potential enum_string(:Damage, :SevereDamage)
friable :boolean
percent_damage :integer
accessible :boolean
notes :text
timestamps
end
inline_booleans true
belongs_to :material
belongs_to :location
...
end
The resulting auto generated form for Location is
<def tag="form" for="Location">
<form merge param="default">
<error-messages param/>
<field-list fields="name, location_materials, space" param/>
<div param="actions">
<submit label="#{ht 'location.actions.save', :default=>['Save']}"
param/><or-cancel param="cancel"/>
</div>
</form>
</def>
This works fine but I want to make some changes to the location_materials
fields. IE ignore some, reorder them etc. I tried
location_material.condition and location_material[condition] or even
a separate extended tag form for LocationMaterial but none of it worked.
Any hints towards this would be appreciated.
Thanks
Bob
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/hobousers/-/xte_H9W4mXAJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en.