Nested templates with dependent scope

The compiler told you exactly what to do. Write typename before ptrModel<std::vector<Data> >::Type, like so: typedef typename ptrModel<std::vector<Data> >::Type Type; The reason for this requirement is that the compiler doesn’t at this point know whether ptrModel<std::vector<Data> >::Type describes a member variable or a nested type. It can’t even figure that out by looking at the … Read more

Javascript: how to dynamically create nested objects using object names given by an array

Put in a function, short and fast (no recursion). var createNestedObject = function( base, names ) { for( var i = 0; i < names.length; i++ ) { base = base[ names[i] ] = base[ names[i] ] || {}; } }; // Usage: createNestedObject( window, [“shapes”, “triangle”, “points”] ); // Now window.shapes.triangle.points is an empty … Read more

How can I update a property of an object that is contained in an array of a parent object using mongodb?

You need to use the Dot Notation for the arrays. That is, you should replace the $ with the zero-based index of the element you’re trying to update. For example: db.users.update ({_id: ‘123’}, { ‘$set’: {“friends.0.emails.0.email” : ‘2222’} }); will update the first email of the first friend, and db.users.update ({_id: ‘123’}, { ‘$set’: {“friends.0.emails.1.email” … Read more

Rails nested form with has_many :through, how to edit attributes of join model?

Figured out the answer. The trick was: @topic.linkers.build.build_article That builds the linkers, then builds the article for each linker. So, in the models: topic.rb needs accepts_nested_attributes_for :linkers linker.rb needs accepts_nested_attributes_for :article Then in the form: <%= form_for(@topic) do |topic_form| %> …fields… <%= topic_form.fields_for :linkers do |linker_form| %> …linker fields… <%= linker_form.fields_for :article do |article_form| %> … Read more