I have a typical method in controller:

  def create
    @user = User.new(params[:user])
    if @user.save
      flash[:notice] = "Successfully created user."
      redirect_to @user
    else
      render :action => 'new'
    end
  end

I thought it automatically saves the attribute :role_ids

I need to explicitly save it?

On 25 mayo, 10:23, Frederick Cheung <[email protected]>
wrote:
> On May 24, 11:08 pm, Alexander <[email protected]> wrote:
>
> > In the view form of user
>
> >     - for user in User.all
> >       = check_box_tag 'role[user_ids][]', user.id, @role.users.include?
> > (user)
> >       =h user.name
>
> > When I create a new user, nothing happens, the array of user_ids is
> > empty
>
> Those checkboxes will result in params['role[user_ids]'] being set to
> an array of user ids - What does your controller code look like? If
> it's just a classic User.create params[:user] that clearly isn't being
> used at all
>
> Fred
>
>
>
> > --
> > 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 
> > athttp://groups.google.com/group/rubyonrails-talk?hl=en.
>
> --
> 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 
> athttp://groups.google.com/group/rubyonrails-talk?hl=en.

-- 
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.

Reply via email to