3 Models Has_many


#1

Bonjour,

J’ai 3 models

class Pay < ActiveRecord::Base

set_table_name “Pays”
set_primary_key “CodePays”

has_many :code_postaux, :class_name =>
“CodesPostaux”, :foreign_key => “CodePays”
has_many :zones,
:class_name => “ZonesGraphique”,
:foreign_key => “CodePays”
end

class ZonesGraphique < ActiveRecord::Base

set_primary_key “IDZoneGeographique”
set_table_name “ZonesGraphiques”

belongs_to :pay, :class_name => “Pay”, :foreign_key => “CodePays”

has_many :distributeurs,
:class_name => “Distributeur”,
:select => “DISTINCT IDCodePostal”,
:foreign_key => “IDZoneGeographique”
end

class Distributeur < ActiveRecord::Base
set_table_name “Expay_Distributeurs”
set_primary_key “IDDistributeur”

belongs_to :code_postal, :class_name =>

“CodesPostaux”, :foreign_key => “IDCodePostal”
belongs_to :zone_geo, :class_name =>
“ZonesGraphique”, :foreign_key => “IDZoneGeographique”
end

J’aimerais afficher par pays toutes les zones qui ont des
distributeurs. Mais je bloque

Un tit coup de main :slight_smile:

Merci

Bolo M.
removed_email_address@domain.invalid
http://blog.developpez.com/index.php?blog=30