DEV Community

Discussion on: Export Records to CSV Files with Rails

Collapse
 
nuno101 profile image
Nuno

Nice, but there's a mistake in the controller/ model. The code appears to work because @users=User.all which matches the set of users computed within the model class

The correct call would be User.to_csv(@users). The User model function has to be modified to take the new parameter into account.

Collapse
 
victorhazbun profile image
Victor Hazbun

nope, it's right the way it is. Since @users is an ActiveRecord::Relation so you can say @users.to_csv