How to pass more than one constructor argument in a build_association call in Rails 3?

To answer your question - you can't. Simply because build_foo has only one parameter defined in documentation which is arguments = {} so you should pass there only arguments hash to initialize your new record.

To answer your question - you can't. Simply because build_foo has only one parameter defined in documentation, which is arguments = {}, so you should pass there only arguments hash to initialize your new record. Also you don't need to call #super in #initialize, as AR::Base doesn't define #initialize itself.

Why do you need to pass 2 distinct arguments instead of arguments hash? Positional arguments doesn't tell you which value you set, and with AR objects you probably has more than one attribute in table.

Thank you MBO. In the real code (vs. the simplified version shown above), I was doing fine without an arguments hash because the arguments are all instances of different user-defined classes (i.e. Argsn.

Is_a? ClassA, argsm. Is_a?

ClassB, etc). The argument position is not important since I was able to get the class via is_a? And therefore identify which argument it is.

But now given your explanation I will consider taking a arguments {}. Thank you for your help. – Marcos Sainz Jun 14 at 6:56.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions