Creating Accounts with Subusers

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs