RailsApps / rails-stripe-membership-saas

An example Rails 4.2 app with Stripe and the Payola gem for a membership or subscription site.
http://railsapps.github.io/rails-stripe-membership-saas
1.14k stars 232 forks source link

Seeding the DB creates duplicate roles. #41

Closed dugjason closed 11 years ago

dugjason commented 11 years ago

I came across this by installing the app, and following the tutorial. I hit rake db:reset, followed by rake db:migrate then rake db:seed. When the DB is reset, the example users are added to the DB by default, so seeding the DB creates these roles again:

sqlite> select * from roles; 1|admin|||2012-12-13 22:59:52.818886|2012-12-13 22:59:52.818886 2|silver|||2012-12-13 22:59:52.826111|2012-12-13 22:59:52.826111 3|gold|||2012-12-13 22:59:52.828903|2012-12-13 22:59:52.828903 4|platinum|||2012-12-13 22:59:52.842543|2012-12-13 22:59:52.842543 5|admin|||2012-12-13 23:00:27.967197|2012-12-13 23:00:27.967197 6|silver|||2012-12-13 23:00:27.980432|2012-12-13 23:00:27.980432 7|gold|||2012-12-13 23:00:27.983743|2012-12-13 23:00:27.983743 8|platinum|||2012-12-13 23:00:27.998622|2012-12-13 23:00:27.998622

stevecastaneda commented 11 years ago

I ran into this too and had to manually delete roles. Could we solve this by using the find_or_create_by_name helper method when creating development roles?

DanielKehoe commented 11 years ago

Thanks @dugjason for reporting the issue and thanks @stevecastaneda for the helpful suggestion. It's great to see a solution offered before I even address the issue.