diff --git a/app/controllers/internal/classified_listings_controller.rb b/app/controllers/internal/classified_listings_controller.rb index 5606a4e6a..cd9390be7 100644 --- a/app/controllers/internal/classified_listings_controller.rb +++ b/app/controllers/internal/classified_listings_controller.rb @@ -2,7 +2,8 @@ class Internal::ClassifiedListingsController < Internal::ApplicationController layout "internal" def index - @classified_listings = ClassifiedListing.all + @classified_listings = ClassifiedListing.page(params[:page]).per(50) + @classified_listings = @classified_listings.joins(:user).where("classified_listings.title ILIKE :search OR users.username ILIKE :search", search: "%#{params[:search]}%") if params[:search].present? end def edit diff --git a/app/models/organization.rb b/app/models/organization.rb index af1aceb48..de4f70be6 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -11,6 +11,7 @@ class Organization < ApplicationRecord has_many :display_ads has_many :notifications has_many :credits + has_many :classified_listings validates :name, :summary, :url, :profile_image, presence: true validates :name, diff --git a/app/models/user.rb b/app/models/user.rb index 8df744f7c..5cd285f6d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -35,6 +35,7 @@ class User < ApplicationRecord has_many :html_variants, dependent: :destroy has_many :page_views has_many :credits + has_many :classified_listings has_many :mentor_relationships_as_mentee, class_name: "MentorRelationship", foreign_key: "mentee_id", inverse_of: :mentee has_many :mentor_relationships_as_mentor, diff --git a/app/views/internal/classified_listings/edit.html.erb b/app/views/internal/classified_listings/edit.html.erb index 56eedb035..55d09e7c3 100644 --- a/app/views/internal/classified_listings/edit.html.erb +++ b/app/views/internal/classified_listings/edit.html.erb @@ -1,6 +1,6 @@ Back to All Listings -