0

I have the following line in my create action:

@financial_goal = current_user.send("build_#{type.underscore}",financial_goal_params)

I'm having trouble with the build method not being defined, because I have not done a :has_one on my User model for all my STI subclasses.

As I explain it, I think I am coming to two options:

A) Instantiate the object straight from the subclass, and skip using build_ then just append the user_id: current_user.id

B) Add all the subclasses as has_one under my user.rb, but that already sounds horrible since every time I create new subclass I'll have to add the association.

Looks like option A it is?

RudyOnRails
  • 1,819
  • 3
  • 17
  • 26

1 Answers1

0

In order to keep things moving, I think the most reasonable way is to dodge the build_ methods and just go with this:

@financial_goal = klass.new(financial_goal_params.merge(user_id: current_user.id))
RudyOnRails
  • 1,819
  • 3
  • 17
  • 26