you are right, my mistake
in the user form i have this
- for role in Role.all
= check_box_tag "user[role_ids][]", role.id, @user.roles.include?
(role)
=h role.name
On 25 mayo, 13:56, Frederick Cheung <[email protected]>
wrote:
> On May 25, 12:35 pm, Alexander <[email protected]> wrote:
>
> > 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
>
> But that's not what your form (at least not in your initial post) is
> doing - it's setting the attribute :user_ids in params[:role] which
> you aren't using. Did you actually mean to create a checkbox
> user[role_ids][] for each role ?
>
> 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 at
http://groups.google.com/group/rubyonrails-talk?hl=en.