1

I have a straightforward question, I've got an instance variable "@fam_act.count" which counts the number of activities performed by a family.

My code in the view reads

Completed <%= @bal_act.count %> Activities

Currently if a family has completed just one activity, it reads, "Completed 1 Activities". I would like to add some conditional logic so that if Activities equals 1 it will display "Activity" instead of "Activities"

Something like: If @bal_act.count == 1 render "Activity" else "Activities"

What is the correct syntax?

Thanks

1 Answer 1

2

You can use pluralize

Completed <%= pluralize(@bal_act.count, 'Activity', 'Activities') %>
Sign up to request clarification or add additional context in comments.

1 Comment

Works. Thanks so much, I knew there had to be a cool Ruby method for that. - Thx HungryCoder

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.