PiRSquared17 / activescaffold

Automatically exported from code.google.com/p/activescaffold
MIT License
0 stars 0 forks source link

Polymorphic assoc. How to figure out parent model class name inside helper? #757

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
There is Item polymorphic model. 

One of it's attributes is Product. And I want to have different Product 
listings according to Item's parent class (nested).

And I have put a lot effort in to this problem and yet can't find the solution.

To better understand the problem, there is my ItemsHelper:

module ItemsHelper

  def options_for_association_conditions(assoc)
    if assoc.name == :product
      case METHOD_TO_ACCESS_CURRENT_PARENT_CLASS_NAME
      when "Invoice"
        one condition
      when
        another condition
      else
        super
      end
    else
      super
    end
  end

end

I will be very grateful for any solution.

Original issue reported on code.google.com by shara...@gmail.com on 12 Jul 2010 at 7:30

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Delete this

Original comment by shara...@gmail.com on 17 Jul 2010 at 8:45

GoogleCodeExporter commented 9 years ago

Original comment by sergio.c...@gmail.com on 19 Jul 2010 at 6:59