RailsApps / rails-devise-pundit

Rails 5.0 starter app with Devise for authentication and Pundit for authorization.
http://railsapps.github.io/rails-devise-pundit/
483 stars 156 forks source link

Admin name when seeding #12

Closed binyamindavid closed 10 years ago

binyamindavid commented 10 years ago

I think you are missing admin name when seeding.

class CreateAdminService
  def call
    user = User.find_or_create_by!(email: Rails.application.secrets.admin_email) do |user|
        user.name= Rails.application.secrets.admin_name
        user.password = Rails.application.secrets.admin_password
        user.password_confirmation = Rails.application.secrets.admin_password
        user.admin!
      end
  end
end
DanielKehoe commented 10 years ago

The user name is strictly optional (not required by the User model).

Is there a compelling reason to set the admin user's name when seeding? Presumably the admin will log in to change his password, at which time he can provide his name if he wants.

binyamindavid commented 10 years ago

I thought it was missing simply because you provided it on the secrets.yml

development:
  admin_name: First User
  admin_email: user@example.com

And i thought i thought the users list did not look neat with missing data. But i hear your argument and i think it`s not a big problem. One can always do what you mention on your comment.

DanielKehoe commented 10 years ago

Thanks for pointing out the inconsistency. It could be confusing.