Hello all,
I have a syntax question. How does one refer to a field brought in via
a
has_one/belongs_to relationship in a form helper? Basically, I have two
models:
class Resource < ActiveRecord::Base
has_one :other_thing
end
class OtherThing < ActiveRecord::Base
belongs_to :resource
end
It has the normal id-resource_id foreign key relationship. OtherThing
has
two fields, plus the foreign key, call them field1 and field2.
In the ruby console, I can access field1 a couple of ways:
resource.other_thing.field1
resource.other_thing[‘field1’]
Maybe a few other ways.
What I want is to update field1 in a form that also updates fields in
the
resources table. It’s simple for fields that REALLY belong to resource,
but
seemingly a problem for related fields in other tables.
select(:resource, :status, @statuses) works fine, for instance.
I’m looking for
select(:resource.other_thing, :field1, @options),
select(:resource, :other_thing.field1, @options),
select(‘resource’, ‘other_thing.field1’, @options),
select(:resource, :other_thing[:field1], @options)
or something to like that, but no luck.
Anyone have any thoughts on the proper syntax?
Thanks in advance,
-Ron