Dies ist der Fehler, den ich bekommen:Wie bekomme ich Fehler "unerkannt Token:" # "" für eine Suchanfrage in Rails?
SQLite3::SQLException: unrecognized token: "#": SELECT "posts"."id" AS
t0_r0, "posts"."title" AS t0_r1, "posts"."content" AS t0_r2,
"posts"."created_at" AS t0_r3, "posts"."updated_at" AS t0_r4,
"posts"."user_id" AS t0_r5, "posts"."course_id" AS t0_r6,
"courses"."id" AS t1_r0, "courses"."name" AS t1_r1,
"courses"."created_at" AS t1_r2, "courses"."updated_at" AS t1_r3,
"courses"."major_id" AS t1_r4, "courses"."user_id" AS t1_r5 FROM
"posts" LEFT OUTER JOIN "courses" ON "courses"."id" =
"posts"."course_id" WHERE (courses.name IN (#{s},#{s})) ORDER BY
posts.created_at DESC
Für diese Abfrage:
@posts = Post.includes(:course).where("courses.name IN (#{@user.courses.map(&:name).collect { |s| '#{s}' }.join(',') })").references(:courses).order("posts.created_at DESC")
Ich verstehe nicht, warum # {s} im Array die Saiten nicht geworden