filterrific icon indicating copy to clipboard operation
filterrific copied to clipboard

It is possible that filterrific to cancel my @jobs = Job.jobs_by(current_user)

Open ovi-tsb opened this issue 7 years ago • 1 comments

I have in my jobs_controller def index @jobs = Job.jobs_by(current_user)

and in job.rb model scope :jobs_by, ->(user) { where(user_id: user.id) }

This should let users to see only jobs what they created, but now it show me jobs from all users. Do you think is something in filterrific what can cancel Job.jobs_by(current_user) ?

ovi-tsb avatar Dec 05 '18 18:12 ovi-tsb

What is the rest of your controller code?

What I did, is in the controller define a default scope. So for example in the Filterrific demo, Student with a default scope of for example freshman (making it up):

def index
    (@filterrific = initialize_filterrific(
      Student.freshman,
      params[:filterrific],
      select_options: {
        sorted_by: Student.options_for_sorted_by,
        with_country_id: Country.options_for_select,
      },
    )) || return
    @students = @filterrific.find.page(params[:page])

    respond_to do |format|
      format.html
      format.js
    end
  end

Hopefully, this is the correct approach...?

cartond avatar Aug 28 '19 19:08 cartond