Reputation: 1435
I have an ActiveRecord model called Student, and Student.first has following attributes:
reg_no: "ABC001",school_fees: 10000.0,transaction_date: "2017-08-19"
I want to convert this into this:
reg_no=ABC001|school_fees=10000.0|transaction_date=2017-08-19
and assign it to a variable to perform encryption and decryption in that variable. How can I get this result?
Upvotes: 2
Views: 2316
Reputation: 1317
Try this:
student = Student.first
student.attributes.map { |key, value| "#{key}=#{value}" }.join('|')
Upvotes: 5