The application I'm creating works like this:
There is an account (a company)
Users belong to the Account (company)
So when somebody wants to sign up and create an account, it should
create an account, then create a user.
username(User)
password(Users)
company(Account)
So I created a Signup controller. I want to add validation but I don't
have a model (for unique and presence validation)for it because the
signup controller is supposed to create User and Account.
class SignupController < ApplicationController
def new
@account = Account.new
@user = User.new
respond_to do |format|
format.html # new.html.erb
end
end
def create
@account = Account.new(params[:account])
respond_to do |format|
if @account.save
format.html { redirect_to(@account, :notice => 'Account was
successfully created.') }
@user = User.new(params[:user])
@user.account_id = @account.id
if @user.save
format.html { redirect_to(@user, :notice => 'User was
successfully created.') }
else
# user wasn't saved
format.html { render :action => "new" }
end
else
# account wasn't saved
format.html { render :action => "new" }
end
end
end
end
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.