Hi all,
I''m not sure if this is a bug, but I''m having some problem
doing a count, on
a named_scope.
class Claim < ActiveRecord::Base
has_many :items
belongs_to :event
before_save :add_pv
accepts_nested_attributes_for :items, :allow_destroy => true
named_scope :pending, :conditions => {:status => "Pending"}
named_scope :approved, :conditions => {:status => "Approved"}
named_scope :endorsed, :conditions => {:status => "Endorsed"}
end
>> @user.club.claims.pending.count
ActiveRecord::StatementInvalid: Mysql::Error: You have an error in
your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near ''*) AS
count_claims_all FROM `claims` INNER JOIN events ON ( claims.event_id
= ev'' at line 1: SELECT count(`claims`.*) AS count_claims_all FROM
`claims` INNER JOIN events ON ( claims.event_id = events.id ) WHERE
(((`claims`.`status` = ''Pending'') AND (events.club_id = 1 ))
AND
(events.club_id = 1 ))
I don''t really know why count isn''t working here. Can someone
advice?
Warmest regards,
David Chua
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---