I'm new to rails. What I want to do is, assuming that there is a table like the image, I want to divide it into groups for each team and get the values of team A and team B.
On the controller
@team = Team.group ("team"). count
<% @team .each do | c |%> <span><% = c%></span> <% end%>
Is written. Of course, I'm using .count, so
["Team A", 3]
["Team B", 2]
However, it is said that it cannot be used only with .group, so I have added .count for the time being, but I want to output only Team A and Team B.
Is there any way? Thank you.
Answer # 1
Team.distinct.pluck (: team)Is it no good?
- ruby on rails - the graph is not displayed well in the app using rails a 0 will be entered in the date when no data is entered,
- ruby - [rails] i want to deploy a rails application using elastic beanstalk
- ruby on rails - [rails 6] i'm using bootstrap 4, but the layout collapses only after logging out
- ruby - about routing using rails collection
- [ruby on rails 6] i implemented the tag function using acts-as-taggable-on, but i can't jump to the linked article from the list
- ruby - [rails] i want to create an image link using the url of the image output using active storage
- ruby - [rails] i want to find the date difference using the model created_at
- ruby on rails - no data when using v-if
- ruby on rails 5 - star evaluation using raty stars become very large
- ruby on rails - i can't comment out using htmlerb begin
- ruby on rails - about deploying apps using s3 function
- ruby - i want to solve the n + 1 problem when using rails where method in loop processing
- ruby - i want to get it at intervals by searching using rails active record
- ruby on rails - [rails] i want to define routing using the resources method
- i want to keep data consistent using [ruby on rails] transaction and payjp
- ruby - [rails 5] i want to send an email to a specific user using action mailer
- ruby on rails - time out when connecting with deployment using ec2, rds
- ruby on rails - i'm using payjpjs v2 i want to register the card name
- ruby on rails - when a photo is added to a folder on the pc, i want to display it on the browser of the web application!
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to call a child component method from a parent in vuejs
- i want to check the type of a shell script variable