I have an inner join query that Action Record can’t seem to pull off
conventionally, so I’m trying to use :finder_sql to utilize an sql query
that works beautifully in SQL. The problem is, when I try to call the
method, I get the following:
private method `gsub’ called for #Array:0x267de04
Here is my has_many code:
has_many :mod_privileges,
:finder_sql => [‘SELECT assignments.* FROM assignments INNER
JOIN permissions ON assignments.publisher_id = permissions.publisher_id
WHERE permissions.user_id = #{current_user.id} AND (permissions.role_id
= 3 OR (permissions.role_id = 4 and permissions.assignment_id =
assignments.id))’]
and a simple test bit I threw into the view:
<%= debug(current_user.mod_privileges) %>
I was using has_many :through, but there seemed to be no way to do an
inner join on something other than the column referencing the main
select table.
Suggestions?