skip to Main Content

Why the count alias column is not returned as part of ActiveRecord_Relation? – Postgresql

I have two tables. StudentGroup and StudentGroupsMembers. StudentGroup.id = StudentGroupMembers.group_id is the foreign key relation. sg = StudentGroup.joins(:student_group_members).select(" student_groups.id, student_groups.name, count(student_group_members.id) as cnt ").group('student_group_members.group_id, student_groups.name, student_groups.id').where(id: [3,4,5,6,6,7,7,8,8]).where("student_group_members.member_type='ra'") This return ActiveRecord_Relation [#<StudentGroup:0x00007fc11253d088 id: 3, name: "Blah">, #<StudentGroup:0x00007fc11253cc78 id: 4, name: "Foo">,…

VIEW QUESTION

How to count total results with ajax? – Laravel

Have a problem with total count of ajax searche's results. There is a mistake "Method IlluminateDatabaseEloquentCollection::total does not exist." if I use directive for example <div class="searched-item"> <a href="#" class="searched-item-res1">{{ __('main.res_found') }} {{$sfilms->total()}} {{ __('main.res_results') }}</a> </div> How to fix…

VIEW QUESTION
Back To Top
Search