How to write contents of a rails database to external file
- by user1296787
I'm trying to have rails send the contents of my database to an external textfile.
I wanted this done everytime a new user is created. 
However, when i try to do the following in my user.rb model file, 
before_save :write_data
def write_data()
    File.open("data.txt", "w") do |myfile|
        myfile.write(User.all)
    end
end
It doesn't write the actual contents of the database, instead, it displays something like this
User:0x109858540
Can anyone help? Thanks.