ruby on rails - SQLite3::SQLException: unrecognized token: ":": -
i'm having trouble running pg_search. think it's set correctly, reason when trying run search, comes up:
sqlite3::sqlexception: unrecognized token: ":": select "courses".*, ((ts_rank((to_tsvector('simple', coalesce("courses"."title"::text, ''))), (to_tsquery('simple', ''' ' || 'finance' || ' ''')), 0))) pg_search_rank "courses" (((to_tsvector('simple', coalesce("courses"."title"::text, ''))) @@ (to_tsquery('simple', ''' ' || 'finance' || ' ''')))) order 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 html:
<% @course.each |courses| %> <div><%= courses %></div> <% end %> is possible caused .each? if keep <%= @course %>, page loads , shows:
#<activerecord::relation:0x....> am supposed convert resulting array before passing .each function?
you have postgresql specific library (pgsearch) , you're using sqlite3 database. pick 1 or other, not both.
the casting operator :: in coalesce("courses"."title"::text, '') valid postgresql only. sqlite can leave out casting (the ::text part), mentioned before, won't pgsearch work correctly unless switch on postgresql database.
Comments
Post a Comment