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.
deleted 18 characters in body; edited title
Source Link
the Tin Man
  • 160.9k
  • 44
  • 222
  • 308

Counting in the view issue?

I'm working with rubyRuby on railsRails, and i didwrote an app aboutapplication to count results in my view, but it is not working.

Here are my tables:

|policies| |id| |num| 1 1234 2 5678 3 1551 |debts| |id| |policy_id| 1 1 2 1 3 2 4 2 5 3 6 2 

I want this:

 |policy_id| |count_num| 1 2 2 3 3 1 

Here is my controller:

class PolicyManagement < ApplicationController def generate_print_cupons @search = Debt.find(:all,:group=>:policy_id) end end 

Here is my model:

class Debt < ActiveRecord::Base belongs_to :policy end class Policy < ActiveRecord::Base has_many :debts end 

This is my view:

 <% @search.each do |debt| %> <%= debt.policy.num %> <% end %> 

I'm trying to count debt.policydebt.policy.num.num

I tried:

 <% @search.each do |debt| %> <%= debt.count(:num) %> <% end %> undefined method `count' for #<ActiveRecord::Associations::BelongsToAssociation:0x7fb5afefd050> 

And also iI tried:

 <% @search.each do |debt| %> <%= debt.num.count %> <% end %> undefined method `count' for 41:Fixnum 

Please somebody can help me with this? I will really appreciate help. Thanks

Counting in the view issue

I'm working with ruby on rails and i did an app about count results in my view but is not working

Here my tables

|policies| |id| |num| 1 1234 2 5678 3 1551 |debts| |id| |policy_id| 1 1 2 1 3 2 4 2 5 3 6 2 

I want this

 |policy_id| |count_num| 1 2 2 3 3 1 

Here is my controller

class PolicyManagement < ApplicationController def generate_print_cupons @search = Debt.find(:all,:group=>:policy_id) end end 

Here my model

class Debt < ActiveRecord::Base belongs_to :policy end class Policy < ActiveRecord::Base has_many :debts end 

This is my view

 <% @search.each do |debt| %> <%= debt.policy.num %> <% end %> 

I'm trying to count debt.policy.num

I tried

 <% @search.each do |debt| %> <%= debt.count(:num) %> <% end %> undefined method `count' for #<ActiveRecord::Associations::BelongsToAssociation:0x7fb5afefd050> 

And also i tried

 <% @search.each do |debt| %> <%= debt.num.count %> <% end %> undefined method `count' for 41:Fixnum 

Please somebody can help me with this? I will really appreciate help. Thanks

Counting in the view issue?

I'm working with Ruby on Rails, and wrote an application to count results in my view, but it is not working.

Here are my tables:

|policies| |id| |num| 1 1234 2 5678 3 1551 |debts| |id| |policy_id| 1 1 2 1 3 2 4 2 5 3 6 2 

I want this:

 |policy_id| |count_num| 1 2 2 3 3 1 

Here is my controller:

class PolicyManagement < ApplicationController def generate_print_cupons @search = Debt.find(:all,:group=>:policy_id) end end 

Here is my model:

class Debt < ActiveRecord::Base belongs_to :policy end class Policy < ActiveRecord::Base has_many :debts end 

This is my view:

 <% @search.each do |debt| %> <%= debt.policy.num %> <% end %> 

I'm trying to count debt.policy.num.

I tried:

 <% @search.each do |debt| %> <%= debt.count(:num) %> <% end %> undefined method `count' for #<ActiveRecord::Associations::BelongsToAssociation:0x7fb5afefd050> 

And also I tried:

 <% @search.each do |debt| %> <%= debt.num.count %> <% end %> undefined method `count' for 41:Fixnum 

Please somebody can help me with this?

more information
Source Link
Carlos Morales
  • 1.1k
  • 3
  • 17
  • 38

I'm working with ruby on rails and i did an app about count results in my view but is not working

Here my tables

|policies| |id| |num| 1 1234 2 5678 3  1551  |debts| |id| |policy_id| 1 1 2 1 3 2 4 2 5 3 6  2 

I want this

 |policy_id| |count_num| 1 2 2 3 3 1  

Here is my controller

class PolicyManagement < ApplicationController def generate_print_cupons @search = Debt.find(:all,:group=>:policy_id) end end 

Here my model

class Debt < ActiveRecord::Base belongs_to :policy end class Policy < ActiveRecord::Base has_many :debts end 

This is my view

 <% @search.each do |debt| %> <%= debt.policy.num %> <% end %> 

I'm trying to count debt.policy.num

I tried

 <% @search.each do |debt| %> <%= debt.count(:num) %> <% end %> undefined method `count' for #<ActiveRecord::Associations::BelongsToAssociation:0x7fb5afefd050> 

And also i tried

 <% @search.each do |debt| %> <%= debt.num.count %> <% end %> undefined method `count' for 41:Fixnum 

Please somebody can help me with this? I will really appreciate help. Thanks

I'm working with ruby on rails and i did an app about count results in my view but is not working

Here my tables

|policies| |id| |num| |debts| |id| |policy_id| 

Here is my controller

class PolicyManagement < ApplicationController def generate_print_cupons @search = Debt.find(:all,:group=>:policy_id) end end 

Here my model

class Debt < ActiveRecord::Base belongs_to :policy end class Policy < ActiveRecord::Base has_many :debts end 

This is my view

 <% @search.each do |debt| %> <%= debt.policy.num %> <% end %> 

I'm trying to count debt.policy.num

I tried

 <% @search.each do |debt| %> <%= debt.count(:num) %> <% end %> undefined method `count' for #<ActiveRecord::Associations::BelongsToAssociation:0x7fb5afefd050> 

And also i tried

 <% @search.each do |debt| %> <%= debt.num.count %> <% end %> undefined method `count' for 41:Fixnum 

Please somebody can help me with this? I will really appreciate help. Thanks

I'm working with ruby on rails and i did an app about count results in my view but is not working

Here my tables

|policies| |id| |num| 1 1234 2 5678 3  1551  |debts| |id| |policy_id| 1 1 2 1 3 2 4 2 5 3 6  2 

I want this

 |policy_id| |count_num| 1 2 2 3 3 1  

Here is my controller

class PolicyManagement < ApplicationController def generate_print_cupons @search = Debt.find(:all,:group=>:policy_id) end end 

Here my model

class Debt < ActiveRecord::Base belongs_to :policy end class Policy < ActiveRecord::Base has_many :debts end 

This is my view

 <% @search.each do |debt| %> <%= debt.policy.num %> <% end %> 

I'm trying to count debt.policy.num

I tried

 <% @search.each do |debt| %> <%= debt.count(:num) %> <% end %> undefined method `count' for #<ActiveRecord::Associations::BelongsToAssociation:0x7fb5afefd050> 

And also i tried

 <% @search.each do |debt| %> <%= debt.num.count %> <% end %> undefined method `count' for 41:Fixnum 

Please somebody can help me with this? I will really appreciate help. Thanks

Source Link
Carlos Morales
  • 1.1k
  • 3
  • 17
  • 38

Counting in the view issue

I'm working with ruby on rails and i did an app about count results in my view but is not working

Here my tables

|policies| |id| |num| |debts| |id| |policy_id| 

Here is my controller

class PolicyManagement < ApplicationController def generate_print_cupons @search = Debt.find(:all,:group=>:policy_id) end end 

Here my model

class Debt < ActiveRecord::Base belongs_to :policy end class Policy < ActiveRecord::Base has_many :debts end 

This is my view

 <% @search.each do |debt| %> <%= debt.policy.num %> <% end %> 

I'm trying to count debt.policy.num

I tried

 <% @search.each do |debt| %> <%= debt.count(:num) %> <% end %> undefined method `count' for #<ActiveRecord::Associations::BelongsToAssociation:0x7fb5afefd050> 

And also i tried

 <% @search.each do |debt| %> <%= debt.num.count %> <% end %> undefined method `count' for 41:Fixnum 

Please somebody can help me with this? I will really appreciate help. Thanks