Append multiple attribute values inside csv You should try to avoid writing CSV yourself, Ruby has a CSV class included that does all escaping for you.
1 2 3 4 5 6 7 8 | unwanted_attributes = ["author", "images", "guid", "link"] sanitized_attributes = article.attributes.select { |attribute_name, _| !unwanted_attributes.include?(attribute_name) } csv_string = CSV.generate do |csv| csv << sanitized_attributes.values end |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.