isjaylee/wedviews — pull request #9 by ab22 (2014-11-11 19:48:31+00:00)
Title: Default user role

[Before you run this, make sure to remove the User.destroy_all line, because it will remove all users in your table.]
To test the changes run in console: rake db:seed

If you see the seeds.rb file, I added a test User to be created, and once that is created, the default role will be set. This is done via: before_create :set_default_role

Before calling User.create, it will set the default role to self.role = 'registered'. It works with after_create too, the thing is, after_create was not saving the data, so I think a self.save was needed there to update the changes again, but hitting the database twice is not worth it for this small change, and that's why I used before_create.