Creating the default admin user following installation

Skip to first unread message


Feb 19, 2014, 11:35:07 AM2/19/14
Hello all,

I'm new to Rails but coming from another language so I understand a little of what is going on. I've been able to successfully set up the default CE site, but have yet to set up email sending so my local "sign-up" attempts are not working as I suspect there is a flag that is set when a user follows a "confirmation" link in an email.

So, I'd like to at least set up a default administrative user - I see that in the source for the CE master there is a db/sample directory - and under that a "users.rb" file - in which there seems to be some methods for setting up the default admin user.

Where/how should I execute this .rb file? Should I put it in with the migrations folder in the gem directory for CE? Should I put it in the migrations folder for the site itself? I'm also thinking ahead for when I deploy this app on Cloudnine and I'll need this file to execute as part of the setup process.


Peter Bethke

Dan Coutu

Feb 19, 2014, 2:23:45 PM2/19/14
Peter, here's a short description of some useful things to know that
will help you:

First of all let introduce the concept of a RAILS_ROOT directory. This
is the top level directory of your Community Engine application. You
will see within it directory names like app, config, db, log, lib,
public and so forth. Set your current working directory to be this
directory from within a terminal (command line) window.

From this directory you can do a number of things via the command line.

So to answer your first question about how to create an admin user type
something like this:

rake community_engine:make_admin

If you need to activate the user that is easy too. You have two options:
read your log file in the log directory and you will find a copy of the
email message that failed to get sent to you. Copy/paste the URL for
activation from it.

The alternative is to use the rails console. This is a great way to do
quick things or to validate your code theories before committing code
changes to source control.

rails console

The above starts up the rails console and shows the prompt that you get.
You can now fetch a user record. There are many possible ways but the
basic method is:

u = User.find 1

This will fetch the user record from the DB having id value of 1. That's
probably the new account that you just made. Now you can operate on u to
change the user record. A user record is activated when it has a valid
date/time stored. Here's how you do that:

u.activated_at =

You then need to save your change to the DB like this:

If in the future you need reset a password on a user account you would
first fetch the account record. In that case you might know the user's
email address and so you could fetch the account like this:

u = User.find_by_email ''

Then you can change their password like this:

u.password = u.password_confirmation = 'the new password'

I hope this helps!

> --
> You received this message because you are subscribed to the Google
> Groups "CommunityEngine" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
> To post to this group, send email to
> Visit this group at
> For more options, visit

Reply all
Reply to author
0 new messages