2

I'm trying out IR and im having some issues setting an instance variable to a nested parent object. For example, I have a professional model that has many projects. In my projects controller, I have this:

class ProjectsController < InheritedResources::Base
   belongs_to :professional, :optional => true

And for all the actions I want to set a @professional instance variable for the parent project.

I tried a before filter, like this:

class ProjectsController < InheritedResources::Base
   belongs_to :professional, :optional => true

   before_filter :set_professional

   private

   def set_professional
      @professional = @project.professional
   end

But I believe it's being called before IR has a chance to set the @project instance variable.

How can I do this?

JoshL
  • 1,397
  • 1
  • 12
  • 28

0 Answers0