RailsApps / rails3-bootstrap-devise-cancan

Outdated. See the rails-devise-pundit example app for Rails 4.1.
http://railsapps.github.io
491 stars 207 forks source link

Database seeds not working #26

Closed rceee closed 11 years ago

rceee commented 11 years ago

I've successfully installed a new rails app using the standard rails composer command (and hitting option 4, for rails3-bootstrap-devise-cancan). The first time, I modified application.yml accordingly, and tried both db:seed and db:reset. The user simply will not load. I tried again, this time leaving the default info in application.yml just to be sure. I see the puts messages when db:seed runs, and there are no errors, but the seed data simply will not load into the database.

If I run the app, I can create a new user without issue, but it is, of course, not an admin user. I could manually go in to the database and change the role, but I don't understand why the seed data isn't loading. Very strange! Anyone else experienced this?

tomassliz commented 11 years ago

Try use password longer than 8 characters. In my situation was problem here. Maybe password restrictions was changed in CanCan configuration, actual application present too short password in seed.rb and in application.yml.

Tomáš Slíž

On Tuesday, January 15, 2013 at 11:26 PM, Richard Carey wrote:

I've successfully installed a new rails app using the standard rails composer command (and hitting option 4, for rails3-bootstrap-devise-cancan). The first time, I modified application.yml accordingly, and tried both db:seed and db:reset. The user simply will not load. I tried again, this time leaving the default info in application.yml just to be sure. I see the puts messages when db:seed runs, and there are no errors, but the seed data simply will not load into the database. If I run the app, I can create a new user without issue, but it is, of course, not an admin user. I could manually go in to the database and change the role, but I don't understand why the seed data isn't loading. Very strange! Anyone else experienced this?

— Reply to this email directly or view it on GitHub (https://github.com/RailsApps/rails3-bootstrap-devise-cancan/issues/26).

rceee commented 11 years ago

I think you nailed it. I copied over the code at https://github.com/grigio/rails-composer-app/blob/master/db/seeds.rb, which does the same thing but does not use the Figaro ENV variables, and received the "password too short" validation error.

Thus, it would seem that out of the box, this setup is not accessing the ENV variables correctly, or something along that line. When I used the code on the above URL (same concept but without Figaro ENV variables), I received successful "New User Created" messages, which I did not during the stock install, or after changing application.yml password (yet, even with application.yml password that is too short, I did not receive the length validation error as I did when I used the seed code from the above URL; it just completely ignores it and doesn't make the users nor give an error–strange).

Update: yeah, updating application.yml to something like

ADMIN_PASSWORD: please123

Lets it got off without a hitch. Maybe either update that default application.yml or explain in build output that password must be > 8 chars.

DanielKehoe commented 11 years ago

Devise version 2.2.0 increased the default minimum password length from six to eight. I've updated the example applications, tutorials, and README. The issue is resolved.