On 31 July 2011 20:00, Linus Pettersson <[email protected]> wrote: > Hi! > Let's say I have an app that handles a TODO list. The list has finished and > unfinished items. Now I want to add two virtual attributes to the list > object; the count of finished and unfinished items in the list. I also need > these to be displayed in the json output. > How do I achieve that?
Define two scopes on List that return the finished and unfinished items then use List.unfinished.count Colin > Best Regards > Linus > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/aFmyk69tHdUJ. > 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/rubyonrails-talk?hl=en. > -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

