# Creating Accounts with Subusers

**URL:** <https://www.ruby-forum.com/t/creating-accounts-with-subusers/144715>\
**Category:** Rails\
**Created:** [August 1, 2008, 1:36pm UTC](https://www.ruby-forum.com/t/creating-accounts-with-subusers/144715 "2008-08-01T13:36:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mroths](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@mroths](https://www.ruby-forum.com/u/mroths)\
**Post date:** [August 1, 2008, 1:36pm UTC](https://www.ruby-forum.com/t/creating-accounts-with-subusers/144715/1 "2008-08-01T13:36:47Z")

</div>

In my model, I have Account has\_many Users. I’m using  
restful\_authentication, so I have the following routes and resources  
defined:

map.resources :accounts  
map.resources :users  
map.resource :session, :controller =\> ‘session’  
map.login ‘/login’, :controller =\> ‘session’, :action =\> ‘new’  
map.logout ‘/logout’, :controller =\> ‘session’, :action =\> ‘destroy’  
map.signup ‘/signup’, :controller =\> ‘accounts’, :action =\> ‘index’  
map.signup ‘/signup/:plan\_type’, :controller =\> ‘accounts’, :action =\>  
‘new’

In my AccountsController#create action, I create both the new account  
and its ‘administrative’ user:

def create  
@account = Account.new(params[:account])  
@account.pricing\_plan = PricingPlan.find\_by\_name(params[:plan\_type])  
@account.users[0].is\_admin = true

respond\_to do |format|  
if @account.save  
flash[:notice] = ‘Account was successfully created.’  
format.html { redirect\_to(@account) }  
format.xml { render :xml =\> @account, :status =\> :created,  
:location =\> @account }  
else  
format.html { render :action =\> “new” }  
format.xml { render :xml =\> @account.errors, :status =\>  
:unprocessable\_entity }  
end  
end  
end

I would like the ability for this administrative user to create  
additional users under the same account. What is the best approach for  
this?

Thanks,  
Mark
