Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 111 characters in body; added 34 characters in body
Source Link
Vamsi
  • 288
  • 2
  • 9

Write this method in user model

#copy the below code in /app/models/user.rb file` def wishes_count counter = 0 self.lists.each do |list| # this is similar to @user.lists  counter += list.wishes.count #this is similar to @list.wishes   end return counter end 

Howdy {Username}, you have made <%=h @user.list.count %> lists, and <%=h @user.wishes_count %> wishes

you can't use @user.wishes.count since user is not directly related to wishes, hope this solution works for you. If any questions please drop a comment.

Write this method in user model

def wishes_count counter = 0 lists.each do |list| counter += list.wishes.count counter end 

Howdy {Username}, you have made <%=h @user.list.count %> lists, and <%=h @user.wishes_count %> wishes

you can't use @user.wishes.count since user is not directly related to wishes, hope this solution works for you. If any questions please drop a comment.

Write this method in user model

#copy the below code in /app/models/user.rb file` def wishes_count counter = 0 self.lists.each do |list| # this is similar to @user.lists  counter += list.wishes.count #this is similar to @list.wishes   end return counter end 

Howdy {Username}, you have made <%=h @user.list.count %> lists, and <%=h @user.wishes_count %> wishes

you can't use @user.wishes.count since user is not directly related to wishes, hope this solution works for you. If any questions please drop a comment.

Source Link
Vamsi
  • 288
  • 2
  • 9

Write this method in user model

def wishes_count counter = 0 lists.each do |list| counter += list.wishes.count counter end 

Howdy {Username}, you have made <%=h @user.list.count %> lists, and <%=h @user.wishes_count %> wishes

you can't use @user.wishes.count since user is not directly related to wishes, hope this solution works for you. If any questions please drop a comment.