I know that we can add records like record.posts << Post.find(1);
but how can add the same Post.find(1) record if I have a variable that contains the name "posts" I have something like this column_name = "posts" record[column_name] << Post.find(1); it is throwing an error NoMethodError (undefined method `<<' for nil:NilClass): -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/37653483-f4fb-4058-94eb-bb8bb87653d5%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

