Using Rails 6 rc1, I'm doing a query on a model called 'Job'.

Job Model (job.rb):

has_rich_text :description
belongs_to :company, dependent: :destroy, required: false

  joins(:company, :description)
  .where.not(has_ended: true)
  .where("jobs.title ILIKE ?", query)
  .where("jobs.description ILIKE ?", query)
  .where(" ~* ?", "^#{query}") #

That's exactly what I have. So far my issue is with the inclusion of has_rich_text. The error, when replicated in the rails console Job.joins(:description):

ActiveRecord::AssociationNotFoundError (Association named 'description' was not found on Job; perhaps you misspelled it?

When searching "hight and low", I could not find any documentation on this level of query. I havent tried scope mentioned here.

1 Answers

Sylar On

It turns out you can! I've posted the menthod on the Rails Github page I've used but need to know if there is a better way.