0

I am getting the following error:

ShowsQueryObject querying for a show by start date returns shows that are after the start date
     Failure/Error: expect(ShowsQueryObject.query(start_date: start_date)).to match_array [after_start_date_show_1, after_start_date_show_2]
     NoMethodError:
       undefined method `query_params' for ShowsQueryObject:Class

For this code:

class ShowsQueryObject
  class << self
    def query(query_params)
      Show.where(query_string(query_params), query_values(query_params))
    end

    private

    def query_string(query_params)
      query_string = []
      query_string << start_date_query if query_params(:start_date)
      query_string << end_date_query if query_params(:end_date)
      query_string << artist_name_query if query_params(:artist_name)
      query_string << venue_id_query if query_params(:venue_id)
      query_string.join(' AND ')
    end

    def query_values(query_params)
      {}.tap do |hash|
        hash[:start_date] = query_params(:start_date) if query_params(:start_date)
        hash[:end_date] = query_params(:end_date) if query_params(:end_date)
        hash[:artist_name] = query_params(:artist_name) if query_params(:artist_name)
        hash[:venue_id] = query_params(:venue_id) if query_params(:venue_id)
      end
    end

    ...
  end
end

I am guessing this has something to do with private static methods in Ruby? This is my first time messing around with class << self so I'm assuming I did something wrong, but from what I can find on line this all looks legit to me.

1 Answer 1

2

You should try changing query_params(:start_date) to query_params[:start_date], because if you put it with "()" ruby takes it as a method and not a property

Sign up to request clarification or add additional context in comments.

1 Comment

Wow, that's embarrassing. That worked though, thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.