Ruby on Rails Sunday, July 31, 2011

On 31 July 2011 20:00, Linus Pettersson <linus.pettersson@gmail.com> 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 rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscribe@googlegroups.com.
> 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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment