Is it possible to put conditions relative to the current instance in
has_many’s :conditions?
For example, in a forum app:
class Post < ActiveRecord::Base
belongs_to :topic
has_many :self_and_descendants, :class_name => “Post”, :order =>
“lft”,
:conditions => “topic_id = #{topic_id} AND (lft BETWEEN #{lft} AND
#{rgt})”
end
With the above code, I get the following exception:
undefined local variable or method `topic_id’ for Post:Class
I’m not interested in whether acts_as_nested_set is a good idea or
already has this functionality. It’s just an example.
So, can you put instance attributes in the :conditions? If so, how?
Many thanks,
Rob Head