Wiebe C. wrote:
I’d like to make a method in the “rating_param” model, which directly
returns the result of the “rating_param_is_leaf” function. How do I go
about that?
I don’t know if this will work but I don’t see a reason why not:
def rating_param§
r = find_by_sql(“SELECT rating_param_is_leaf(#{p.to_i})”).at(0)
r.rating_param_is_leaf
end
Kamil Kukura wrote:
I don’t know if this will work but I don’t see a reason why not:
def rating_param§
r = find_by_sql(“SELECT rating_param_is_leaf(#{p.to_i})”).at(0)
r.rating_param_is_leaf
end
I changed it into:
def is_leaf
r = RatingParam.find_by_sql(“SELECT
rating_param_is_leaf(#{id})”).at(0)
r.rating_param_is_leaf
end
I still don’t think it’s perfect, but I guess it works. Thanks.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Nov 8, 2005, at 4:22 AM, Wiebe C. wrote:
def is_leaf
r = RatingParam.find_by_sql(“SELECT rating_param_is_leaf(#
{id})”).at(0)
r.rating_param_is_leaf
end
I still don’t think it’s perfect, but I guess it works. Thanks.
def leaf?
!self.class.connection.select_value(“SELECT rating_param_is_leaf
(#{quoted_id})”).to_i.zero?
end
jeremy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (Darwin)
iD8DBQFDcKwWAQHALep9HFYRAkiZAJ9DO9nre8xj3DzWGFta3uQQvIysRQCdFeMM
W+Rv0Ouumya1OfFgaAqDiyg=
=3sY9
-----END PGP SIGNATURE-----