On 11 mai, 11:41, "Sergio Cambra .:: entreCables S.L. ::."
<[email protected]> wrote:
> On Martes, 11 de Mayo de 2010 11:33:39 gs84 escribió:
>
> conditions_for_collection only must return the conditions part of a find
> method. Other options as :order or :origin must be set with
> custom_finder_options:
>
> def conditions_for_collection
> "distance < 10" if session[:usager_id] != nil
> end
By using only the conditions_for_collection method, i get an error
like:
"Mysql::Error: Unknown column 'distance' 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 WHERE ((distance < 10))
> def custom_finder_options
> if session[:usager_id] != nil
> commune_usager = Usager.find(session[:usager_id]).commune
> #city of the current usager
> commune_usager_lat = commune_usager.lattitude #lattitude of
> current usager's city
> commune_usager_long = commune_usager.longitude #longitude of
> current usager's city
>
> :order => 'distance ASC', :origin => [commune_usager_lat,
> commune_usager_long]
> else
> {}
> end
> end
> --
For the custom_finder_options method, (because i got a syntax error,
unexpected ',', expecting kEND)
i have add "{}" in the conditions expression like: { :order =>
'distance ASC', :origin => [commune_usager_lat, commune_usager_long] }
here also (when using the two methods), i got error : " Unknown
key(s): origin "
--
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.