anchor.diff:  	<%- has_many = @struct_info[:assoc_info][:has_many] -%>
   	<%- has_many.each do |k, v| -%>
   func (var_<%= model_name_underscore %> *<%= @model_name %>) <%= v[:class_name].pluralize %>Create(am map[string]interface{}) error {
  -	<%- if v[:foreign_key] -%>
  -	am["<%= v[:foreign_key] %>"] = var_<%= model_name_underscore %>.Id
  -    <%- else -%>
  -	am["<%= model_name_underscore %>_id"] = var_<%= model_name_underscore %>.Id
  -	<%- end -%>
  -	err := Create<%= v[:class_name] %>(am)
  +	<%- if v[:through] -%>
  +		// FIXME: use transaction to create these associated objects
  +		<%= v[:class_name].underscore %>_id, err := Create<%= v[:class_name] %>(am)
  +		if err != nil {
  +			return err
  +		}
  +		_, err = Create<%= v[:through].to_s.singularize.camelize %>(map[string]interface{}{"<%= model_name_underscore %>_id": var_<%= model_name_underscore %>.Id, "<%= v[:class_name].underscore %>_id": <%= v[:class_name].underscore %>_id})
  +	<%- else -%>
  +		<%- if v[:foreign_key] -%>
  +			am["<%= v[:foreign_key] %>"] = var_<%= model_name_underscore %>.Id
  +		<%- else -%>
  +			am["<%= model_name_underscore %>_id"] = var_<%= model_name_underscore %>.Id
  +		<%- end -%>
  +		_, err := Create<%= v[:class_name] %>(am)
  +	<%- end -%>
   	return err
   }
   
   func (var_<%= model_name_underscore %> *<%= @model_name %>) Get<%= v[:class_name].pluralize %>() error {
  -	<%- if v[:foreign_key] -%>
  -	var_<%= v[:class_name].underscore.pluralize %>, err := Find<%= v[:class_name].pluralize %>By("<%= v[:foreign_key] %>", var_<%= model_name_underscore %>.Id)
  -    <%- else -%>
  -	var_<%= v[:class_name].underscore.pluralize %>, err := Find<%= v[:class_name].pluralize %>By("<%= model_name_underscore %>_id", var_<%= model_name_underscore %>.Id)
  +	<%- if v[:through] -%>
  +		// FIXME: use transaction to create these associated objects
  +		<%= v[:class_name].underscore %>_ids, err := <%= v[:through].to_s.singularize.camelize %>IntCol("<%= v[:class_name].underscore %>_id", "<%= model_name_underscore %>_id = ?", var_<%= model_name_underscore %>.Id)
  +		if err != nil {
  +			return err
  +		}
  +		var_<%= v[:class_name].underscore.pluralize %>, err := Find<%= v[:class_name].pluralize %>(<%= v[:class_name].underscore %>_ids...)
  +	<%- else -%>
  +		<%- if v[:foreign_key] -%>
  +			var_<%= v[:class_name].underscore.pluralize %>, err := Find<%= v[:class_name].pluralize %>By("<%= v[:foreign_key] %>", var_<%= model_name_underscore %>.Id)
  +		<%- else -%>
  +			var_<%= v[:class_name].underscore.pluralize %>, err := Find<%= v[:class_name].pluralize %>By("<%= model_name_underscore %>_id", var_<%= model_name_underscore %>.Id)
  +		<%- end -%>
   	<%- end -%>
   	if err == nil {
   		var_<%= model_name_underscore %>.<%= k %> = var_<%= v[:class_name].underscore.pluralize %>
  -	}
  -	return err
  +    }
  +    return err
   }
   	<%- end -%>
   <%- end -%>
  
positive.code:     <%- else -%>
  	am["<%= model_name_underscore %>_id"] = var_<%= model_name_underscore %>.Id
  	<%- end -%>
  	err := Create<%= v[:class_name] %>(am)
  	return err
  }
  	<%- end -%>
  
negative.code: 	_, err = stmt.Exec(id)
  	if err != nil {
  		return err
  	}
  	<%- [:has_many, :has_one].each do |ass| -%>
  		<%- ass_cols = @struct_info[:assoc_info][ass] -%>
  		<%- unless ass_cols.empty? -%>
  			<%- ass_cols.each_value do |opts| -%>
  				<%- if opts.key? :dependent -%>
  					<%- if opts[:through] -%>
  						<%= opts[:class_name].underscore %>_ids, err := <%= opts[:through].to_s.singularize.camelize %>IntCol("<%= opts[:class_name].underscore %>_id", "<%= model_name_underscore %>_id = ?", var_<%= model_name_underscore %>.Id)
  						if err != nil {
  							return err
  						}
  						_, err = Destroy<%= opts[:class_name].pluralize %>(<%= opts[:class_name].underscore %>_ids...)
  						if err != nil {
  							return err
  						}
  						_, err = Destroy<%= opts[:through].to_s.pluralize.camelize %>Where("<%= model_name_underscore %>_id = ?", var_<%= model_name_underscore %>.Id)
  						if err != nil {
  							return err
  						}
  					<%- else -%>
  						<%- if opts.key? :foreign_key -%>
  							Destroy<%= opts[:class_name].pluralize %>Where("<%= opts[:foreign_key] %> = ?", id)
  						<%- else -%>
  							Destroy<%= opts[:class_name].pluralize %>Where("<%= model_name_underscore %>_id = ?", id)
  						<%- end -%>
  					<%- end -%>
  				<%- end -%>
  			<%- end -%>
  		<%- end -%>
  	<%- end -%>
  	return nil
  }
  
  func Destroy<%= @model_name.pluralize %>(ids ...int64) (int64, error) {
  	if len(ids) == 0 {
  		msg := "At least one or more ids needed"
  		log.Println(msg)
  		return 0, errors.New(msg)
  	}
  	idsHolder := strings.Repeat(",?", len(ids)-1)
  	sql := fmt.Sprintf(`DELETE FROM <%= table_name %> WHERE id IN (?%s)`, idsHolder)
  	idsT := []interface{}{}
  	for _,id := range ids {
  		idsT = append(idsT, interface{}(id))
  	}
  	stmt, err := db.Preparex(sql)
  	result, err := stmt.Exec(idsT...)
  	if err != nil {
  		return 0, err
  	}
  	cnt, err := result.RowsAffected()
  	if err != nil {
  		return 0, err
  	}
  	<%- [:has_many, :has_one].each do |ass| -%>
  		<%- ass_cols = @struct_info[:assoc_info][ass] -%>
  