Open andrewhubbs opened 11 years ago
This may be a bug in Rails. The error is very similar to this bug and changing the objects I am passing into the partials into arrays seems to fix it.
cache [root_object, root_object.teams.to_a] # << Notice the `to_a`
node :teams do |employee|
partial "teams/index", object: employee.teams.to_a # << Notice the `to_a`
end
Having to do this everywhere seems like a pretty lame solution. Any other thoughts?
So after more digging I think it is a little more complicated. I have narrowed it down to a specific has_many
relation between a few of my models. The relation looks something like this:
class Employee < ActiveRecord::Base
has_many :assigned_items, class_name: ChecklistItem, finder_sql: Proc.new {
%Q{
SELECT "checklist_items".* FROM "checklist_items"
INNER JOIN "checklists" ON "checklists"."id" = "checklist_items"."checklist_id"
WHERE "checklist_items"."employee_id" = #{id} AND "checklist_items"."active" = 't' AND "checklists"."active" = 't'
ORDER BY "checklist_items".created_at
}
}
end
Looks like the finder_sql
is the real culprit here. The to_a
solution above doesn't seem to do the trick either.
While their could be a problem in Rails, I am starting to think this is a RABL
issue with writing cache values that can't be fetched back out. See the issue, referenced above this comment too.
@andrewhubbs did you ever find a solution to this? I'm running into the same issue
+1
The basic error I am getting is this:
My views look something like this:
Any thoughts on what is going on here?
Relevant config: