On Miércoles, 29 de Diciembre de 2010 08:49:19 ruby_noob escribió:
> Hi folks
> i have 3 simple models
> 
> class Region < ActiveRecord::Base
>    has_many :cities
>    has_many :schools, :through => :cities
> end
> 
> class City < ActiveRecord::Base
>   belongs_to :region
>   has_many :schools
> end
> 
> class School < ActiveRecord::Base
>   belongs_to :city
> end
>      1. How to define SchoolsController activescaffold config to add
>         region column?

Add delegate :region, :to => :city to School model.
Add :region to config.columns.

>      2. at SchoolsController is it possible have all columns (region
> and
>         city) add an school and choose region first and scoped city
>         (after changed region)

Define school_region_form_column helper override with all regions.
Set update_column in region column: config.columns[:region].update_column = 
:city
Define options_for_association_conditions helper:
def options_for_association_conditions(association)
  if association.name == :city
    {:region_id => @record.region.try(:id)}
  else
    super
  end
end


-- 
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]

-- 
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