# Handling initial user setup (authlogic)

**URL:** <https://discuss.rubyonrails.org/t/handling-initial-user-setup-authlogic/48200>\
**Category:** rubyonrails-talk\
**Created:** [December 28, 2009, 9:59am UTC](https://discuss.rubyonrails.org/t/handling-initial-user-setup-authlogic/48200 "2009-12-28T09:59:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brianp](https://avatars.discourse-cdn.com/v4/letter/b/94ad74/32.png) [@brianp](https://discuss.rubyonrails.org/u/brianp)\
**Post date:** [December 28, 2009, 9:59am UTC](https://discuss.rubyonrails.org/t/handling-initial-user-setup-authlogic/48200/1 "2009-12-28T09:59:32Z")

</div>

Hey, I was just wondering what you do to handle the initial user setup with a project using authlogic.

I'm still in development but what i find annoying is the create new users function is obviously kept in the admin section. I can't get into the admin section without a user... You see the problem.

In most cases i have an admin user setup but now that i'm so far in development everything is being locked down (ie user creating behind closed doors) and if I make a db change and migrate my user table gets wiped out.

How should I go about migrating with an initial admin user ?

---

<div class="post-metadata">

**Author:** ![Leonardo\_Mateo](https://avatars.discourse-cdn.com/v4/letter/l/f08c70/32.png) [@Leonardo\_Mateo](https://discuss.rubyonrails.org/u/Leonardo_Mateo)\
**Post date:** [December 28, 2009, 2:43pm UTC](https://discuss.rubyonrails.org/t/handling-initial-user-setup-authlogic/48200/2 "2009-12-28T14:43:39Z")

</div>

OK, your question is a bit specific for your application but, one thing you can do is to create a rake task for creating this admin user.

---

<div class="post-metadata">

**Author:** ![brianp](https://avatars.discourse-cdn.com/v4/letter/b/94ad74/32.png) [@brianp](https://discuss.rubyonrails.org/u/brianp)\
**Post date:** [December 29, 2009, 9:03am UTC](https://discuss.rubyonrails.org/t/handling-initial-user-setup-authlogic/48200/3 "2009-12-29T09:03:14Z")

</div>

So as of Rails 2.3.4 they've added a seeding function.

see [http://ryandaigle.com/articles/2009/5/13/what-s-new-in-edge-rails-database-seeding](http://ryandaigle.com/articles/2009/5/13/what-s-new-in-edge-rails-database-seeding) for tutorial.

Basically, add a seeds.rb to the db/ folder.

Fill it out with any ruby code. I used: User.create(:username =\> "admin", :password =\> "temp", :password\_confirmation =\> "temp", :email =\> "admin@temp.com") puts "Created admin account"

then run: rake db:setup

This will migrate the schema and fill the db from your seed data.

Allows better separation of your seed data from your migration files. And a distinct place to do it instead of assorted rake files.

Thankis, for your reply I wouldn't have found it had i not started to search for rake tasks.
