I'm having trouble running pg_search. I think it's set up correctly, but for some reason when trying to run a search, this comes up:
SQLite3::SQLException: unrecognized token: ":": SELECT "courses".*, ((ts_rank((to_tsvector('simple',
coalesce("courses"."title"::text, ''))), (to_tsquery('simple', ''' ' || 'finance' || ' ''')), 0))) AS
pg_search_rank FROM "courses" WHERE (((to_tsvector('simple', coalesce("courses"."title"::text, '')))
@@ (to_tsquery('simple', ''' ' || 'finance' || ' ''')))) ORDER BY pg_search_rank DESC, "courses"."id" ASC
Course model:
include PgSearch
scope :by_course_title, lambda { |ttl|
_by_course_title(ttl) if ttl.present? }
pg_search_scope :_by_course_title, against: :title
Search Controller:
def index
@course = Course.by_course_title(params[:fname])
end
In the html:
<% @course.each do |courses| %>
<div><%= courses %></div>
<% end %>
Is it possible that this is caused by the .each? If I only keep <%= @course %>, the page loads up and shows:
#<ActiveRecord::Relation:0x....>
Am I supposed to convert the resulting array before passing the .each function?