I
I
IvanN7772014-12-01 11:14:17
Ruby on Rails
IvanN777, 2014-12-01 11:14:17

SQLite3::SQLException: ambiguous column name how to fix the problem?

I know that when join there is a name conflict, however
I have a skope in which
the controller is being searched

tasks=Task.initiator_filter(params[:initiator_name])

this is a model
scope :initiator_filter, ->(name){ joins(:initiator).where("users.name LIKE ?", "%{name}%")}

The error message is clear, name conflict.
SQLite3::SQLException: ambiguous column name: id: SELECT "tasks".* FROM "tasks" INNER JOIN "users" ON "users"."id" = "tasks"."initiator_id" WHERE (users.name LIKE '% fdghfgfd%') AND (id IN (NULL))

However, I don't understand where this code snippet comes from.
(id IN (NULL)

to fix it, only the code in the controller above is called.
Sincerely, your fool

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vsuhachev, 2014-12-01
@IvanN777

Go to the console and enter
Next, if the request is normal, then the problem is somewhere in your controller, view or model code (before_action, default_scope, etc.).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question