# Handling initial user setup (authlogic)

**URL:** <https://www.ruby-forum.com/t/handling-initial-user-setup-authlogic/180737>\
**Category:** Rails\
**Created:** [December 28, 2009, 11:02am UTC](https://www.ruby-forum.com/t/handling-initial-user-setup-authlogic/180737 "2009-12-28T11:02:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brianp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/94ad74/32.png) [@brianp](https://www.ruby-forum.com/u/brianp)\
**Post date:** [December 28, 2009, 11:02am UTC](https://www.ruby-forum.com/t/handling-initial-user-setup-authlogic/180737/1 "2009-12-28T11:02:46Z")

</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 ?

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![brianp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/94ad74/32.png) [@brianp](https://www.ruby-forum.com/u/brianp)\
**Post date:** [December 28, 2009, 3:45pm UTC](https://www.ruby-forum.com/t/handling-initial-user-setup-authlogic/180737/2 "2009-12-28T15:45:29Z")

</div>

On Mon, Dec 28, 2009 at 6:59 AM, brianp [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> 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 ?

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.

–  
Leonardo M…  
There’s no place like ~

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![brianp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/94ad74/32.png) [@brianp](https://www.ruby-forum.com/u/brianp)\
**Post date:** [December 29, 2009, 10:04am UTC](https://www.ruby-forum.com/t/handling-initial-user-setup-authlogic/180737/3 "2009-12-29T10:04:50Z")

</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 =\> “removed\_email\_address@domain.invalid”)  
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.

On Dec 28, 6:43 am, Leonardo M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > development everything is being locked down (ie user creating behind  
> > Leonardo M…  
> > There’s no place like ~

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).
