Form is creating already loaded attributes in addition to new attributes, how do I ignore the first?

Posted by looloobs on Stack Overflow See other posts from Stack Overflow or by looloobs
Published on 2010-02-17T22:19:48Z Indexed on 2010/04/17 15:33 UTC
Read the original article Hit count: 217

In my application you:

  1. Have an admin user that signs on and that user has a role (separate model), then I use the declarative_authorization plugin to give access to certain areas.

  2. That admin user can also register new users in the system, when they do this (using Authlogic) they fill out a nested form that includes that new users' role.

So what is happening is the role of the admin user is being loaded by the declarative_authorization and then the nested form using the has_many_nested_attributes is loading that existing role as well as the new role for the new user (users can have many roles).

Is there some way I can tell the new User being created to ignore the role assigned to the current_user and only create the role in the form for the new user?

I have looked through a lot of different things, but it seems to get more complicated that these are nested attributes.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about declarative-authorization