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
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---