RailsApps / rails-stripe-membership-saas

An example Rails 4.2 app with Stripe and the Payola gem for a membership or subscription site.

Home Page:http://railsapps.github.io/rails-stripe-membership-saas

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Seeding the DB creates duplicate roles.

dugjason opened this issue · comments

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

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?

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.