Forums » Development »
How to write new users (imported with csv-files) to database ?
Added by ruben bauwens about 13 years ago
Hello,
I am writing a plugin for redmine, which reads in a csv file and makes projectspaces and users in Redmine.
Now I have already the code for inserting new users:
user = User.find_by_login(row[@headers.index(usernameheader)]) unless user user = User.new(:status => 1, :mail_notification => 0, :language => Setting.default_language) user.login = row[@headers.index(usernameheader)] user.password = row[@headers.index(passwordheader)] user.lastname = row[@headers.index(lastnameheader)] user.firstname = row[@headers.index(firstnameheader)] user.password_confirmation = row[@headers.index(passwordheader)] user.mail = row[@headers.index(mailheader)] user.admin = 1 end #unless user.save
Now this looks correct to me, the user object is not empty, it is correctly filled. But if I go to the view of all users, the users are not added. So they aren't written to the database. Somebody with some help?
Thanks
Replies (1)
RE: How to write new users (imported with csv-files) to database ? - Added by Harry Garrood almost 13 years ago
Is there supposed to be an exclamation mark on the end of save?