How to order a query using all of her data?

Asked

Viewed 35 times

0

My problem is this, I need to order the jobs of all categories according to what is requested in a checked. is a job search site, I need to sort the older Jobs as soon as the checkbox for false, in that case, when it is cleared. Knowing this, I’m not able to return this sort of ordering from the controller side when the checkbox is fake. Summarizing what I wrote: I want to sort the categories, but what I’m able to do is just sort the categories, which is not what I want to do. I’m sorry if it got complicated to understand.

controller code

def index
    @categories = search_jobs
end

def search_jobs
        categories = params[:jobs] != 'checked' ? JobCategory.all : JobCategory.order("id DESC")
end



private
    def job_params

    params.require(:job).permit(:company_name, :site_url,
                                :title, :description, :contact_message,
                                :location, :category_id, :days_to_expire,
                                :vacancy_completed)
end

Someone knows a way I can do it??

  • Could improve the question to try to help?

  • I need to order only the works (Job) of each category.

1 answer

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.