My problem is similar to the thread from the rails forum:
Creating Two Models in One Form http://railsforum.com/viewtopic.php?id=717
My problem is similar to the thread from the rails forum:
Creating Two Models in One Form http://railsforum.com/viewtopic.php?id=717
@user.is_owner_of @menu This will create Role with @user having @menu, then: return true if @user.is_owner_of @menu
OR
you can make: @user.has_role "menu_owner" @menu.accept_role "menu_owner" This will make new role for @user naming "menu_owner" and make @menu accept ANY user having "menu_owner" permission. then: if @user.is_menu_owner_of @menu do {}
This is works well.
Thanks for the suggestion but I am not able to get it to work right.
I am going to try to re-word the original thought:
When someone signs up I would like to save the information they are sending (params[:user]) and add a relationship to an existing menu (in a has_and_belongs_to_many situation).
So when user xxx signs up (and becomes id=5) there is an entry in the menus_users table that is (menu_id 1/user_id 5). This menu (id=1) already exists.
Thanks, Sunny
I wanted to go ahead and post my solution for this thread of questions.
In this scenario the menus table has a column called "kind" and some of the records are named "default".
def signup @user = User.new(params[:user]) return unless request.post? @user.save! self.current_user = @user current_user.menus = Menu.find_all_by_kind('default') redirect_back_or_default(:controller => '/welcome', :action => 'index') flash[:notice] = "Thanks for signing up!" rescue ActiveRecord::RecordInvalid render :action => 'signup' end
Sunny