Josh Susser wrote:> Street
> belongs_to :city, :include => :country
> delegate :country, :country=, :to => :city
Josh,
It is awesome, thanks. That''s what I was looking for. Now, maybe you
would be able to help me also with opposite problem:
class Country < ActiveRecord::Base
has_many :states
has_many :cities, :through => :states
has_many :streets, :through => :cities
It doesn''t work...
I wan''t to use country.streets(...)
I was trying to use :finder_sql => ''SELECT streets.* FROM states,
cities, streets WHERE states.country_id = #{id} AND cities.state_id =
states.id AND streets.city_id = cities.id'' but I get an error:
Mysql::Error: #21000Operand should contain 1 column(s): SELECT * FROM
streets WHERE (SELECT streets.* FROM states, cities, streets WHERE
states.country_id = 1 AND cities.state_id = states.id AND
streets.city_id = cities.id) AND (streets.`subdomain` = ''test''
) LIMIT
1
When using:
@country.streets.find_by_subdomain(@sub.first)
--
Posted via http://www.ruby-forum.com/.