My problem is similar to the thread from the rails forum:
Creating Two Models in One Form
http://railsforum.com/viewtopic.php?id=717
I am using acts_as_authenticated and role_requirement and a model called
“menu” all in one controller “Account” (from acts as authenticated). For
various reasons I wanted menu items to be different than roles. I have
everything working on a basic level.
What I want to do is assign a set of menu items and roles upon signup.
The attempt below will create a new menu when signing up (not what I
want to
do). Ideally I could get the controller to look at a field in the
database
for each table and see if it matched “default” or some other value.
def signup
@user = User.new(params[:user])
@menu = @user.menus.build(attributes={:id => 1})
return unless request.post?
@user.save!
self.current_user = @user
redirect_back_or_default(:controller => ‘/welcome’, :action =>
‘index’)
flash[:notice] = “Thanks for signing up!”
rescue ActiveRecord::RecordInvalid
render :action => ‘signup’
end
I was even thinking about some kind of “after_save()” action that would
assign menu items and roles while the user gets a “thanks for signing
up”
page. I have not used this before so i am not exactly sure how to use
it.
Any advice would be appreciated.
Sunny