On Miércoles, 5 de Mayo de 2010 14:27:27 gs84 escribió:
> I have the following associations with 3 classes: Commune,
> Entiteservice, Offreservice
> class Commune < ActiveRecord::Base
> end
>
> Commune has 2 attributes: lattitude, longitude
>
>
> ['acos(cos(:lattitude)*cos(entiteservices.commune.lattitue)*cos(entiteservi
>ces.commune.longitude-:longitude)
> +sin(:lattitude)*sin(entiteservices.commune.lattitude))*:r < :max',
> {:lattitude => commune_usager_lat, :longitude =>
> commune_usager_long,:r => 6378.138, :max => 10}]
> end
> end
>
> But i am always getting an mysql error "Unknown column
> 'entiteservices.commune.lattitue' " :
The field is lattitude, not lattitue, and the table is communes,
entiteservices.commune.lattitude is wrong, change all entiteservices.commune
with communes, and lattitue with lattitude. You only have to set conditions as
you would do in where clause of a sql query. Anyway, it's cleaner to use
geokit plugin than put so much code in your controller
>
> Mysql::Error: Unknown column 'entiteservices.commune.lattitue' in
> 'where clause': SELECT count(DISTINCT `offreservices`.id) AS count_all
> FROM `offreservices` LEFT OUTER JOIN `entiteservices_offreservices`
> ON `entiteservices_offreservices`.offreservice_id =
> `offreservices`.id LEFT OUTER JOIN `entiteservices` ON
> `entiteservices`.id = `entiteservices_offreservices`.entiteservice_id
> LEFT OUTER JOIN `offreservices_services` ON
> `offreservices_services`.offreservice_id = `offreservices`.id LEFT
> OUTER JOIN `services` ON `services`.id =
> `offreservices_services`.service_id LEFT OUTER JOIN `horaires` ON
> horaires.offreservice_id = offreservices.id LEFT OUTER JOIN
> `communes_offreservices` ON `communes_offreservices`.offreservice_id =
> `offreservices`.id LEFT OUTER JOIN `communes` ON `communes`.id =
> `communes_offreservices`.commune_id WHERE
> ((acos(cos(0.79309216894474)*cos(entiteservices.commune.lattitue)*cos(entit
>eservices.commune.longitude-0.076619951832285)+sin(0.79309216894474)*sin(ent
>iteservices.commune.lattitude))*6378.138 < 10))
>
> Can someone help me to solve this problem or if there is another way
> to do what i want.
--
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.