https://github.com/activescaffold/active_scaffold/wiki/Chaining-Form-Fields
PS: Just out of curiosity, shouldn't your model be something like this?
class CostCode < ActiveRecord::Base
has_many :subcontractors
has_many :orders
end
> --
> 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 actives...@googlegroups.com.
> To unsubscribe from this group, send email to activescaffol...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/activescaffold?hl=en.
>
>
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
module OrdersHelper
def options_for_association_conditions(association)
if association.name == :cost_code
["cost_codes.id" IN @record.subcontractor.costcode_id]
else
super
end
end
2011/10/15 Cláudio Forain <claudi...@gmail.com>:
def options_for_association_conditions(association)
if association.name == :cost_code
["cost_codes.id" IN (?) , @record.subcontractor.costcode_id]
else
super
end
That will solve the error, but let me think further about your relationship.
https://github.com/activescaffold/active_scaffold/wiki/Chaining-Form-Fields
I have never done that, it's just a shot.
2011/10/15 Cláudio Forain <claudi...@gmail.com>:
The code in the helper I told you to use worked for filtering the
select box? (even though I know it's not what you want)
Whats the result of yout after_render_field ?
I was thinking something like triggering the form_override with the
after_render_field and do something that would be like passing a
html_option to the form
config.column[:cost_code].options = {:selected =>
record.sub_contractor.cost_code}
Maybe it's a long shot, but it's all I can think now.
2011/10/15 Cláudio Forain <claudi...@gmail.com>: