I see. I'm not an expert, but I will try to help :p
Considering your tables have these fields:

Order:  subcontractor_id, costcode_id
Subcontractor: costcode_id

Well, here I would try to do something like this in options_helper.rb

module OrdersHelper
  def options_for_association_conditions(association)
    if association.name == :cost_code
      ["cost_codes.id"  IN @record.costcode_id]
    else
      super
    end
  end

That worked around here, you should try.
end

On Sat, Oct 15, 2011 at 11:06 AM, JB <[email protected]> wrote:
> I looked at the wiki article and still couldn't seem to figure it out.
>
> And no, my model really doesn't have the reverse association. The cost
> codes are just a table that provides a bunch of values that can be
> selected for a drop down list that is used in multiple places.
>
> On Oct 15, 8:59 am, Cláudio Forain <[email protected]> wrote:
>> Maybe this will help:
>>
>> https://github.com/activescaffold/active_scaffold/wiki/Chaining-Form-...
>>
>> PS: Just out of curiosity, shouldn't your model be something like this?
>>
>> class CostCode < ActiveRecord::Base
>>   has_many :subcontractors
>>   has_many :orders
>> end
>>
>> On Sat, Oct 15, 2011 at 10:47 AM, JB <[email protected]> wrote:
>> > I have the following model:
>>
>> > class CostCode < ActiveRecord::Base
>> > end
>>
>> > class SubContractor < ActiveRecord::Base
>> >  has_many :orders
>> >  belongs_to :cost_code
>> > end
>>
>> > class Order < ActiveRecord::Base
>> >  belongs_to :sub_contractor
>> >  belongs_to :cost_code
>> > end
>>
>> > The UI for Order.sub_contractor is a select box. When I select the
>> > sub_contractor on the order, how can I chain the fields so that the
>> > sub_contractor.cost_code is used to populate the order.cost_code?
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "ActiveScaffold : Ruby on Rails plugin" group.
>> > 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 
>> > athttp://groups.google.com/group/activescaffold?hl=en.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "ActiveScaffold : Ruby on Rails plugin" group.
> 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/activescaffold?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
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/activescaffold?hl=en.

Reply via email to