# Two models with restful\_authentication

**URL:** <https://www.ruby-forum.com/t/two-models-with-restful-authentication/163318>\
**Category:** Rails\
**Created:** [March 19, 2009, 7:38am UTC](https://www.ruby-forum.com/t/two-models-with-restful-authentication/163318 "2009-03-19T07:38:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![indu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/eada6e/32.png) [@indu](https://www.ruby-forum.com/u/indu)\
**Post date:** [March 19, 2009, 7:38am UTC](https://www.ruby-forum.com/t/two-models-with-restful-authentication/163318/1 "2009-03-19T07:38:27Z")

</div>

Hai everyone,  
I am using restful\_authentication plugin in my project. The relation  
between the category and user is has\_and\_belongs\_to\_many. So I created  
another table category\_users with category\_id and user\_id as fields. In  
my view i specified like the following.  
\<% for category in Category.find(:all) %\>  
\<%= category.name %\>  
\<%= check\_box\_tag(“user[category\_ids][]”,"#{category.id}")  
%\>  
\<%end%\>  
But when I tried to save the user model the categories of the user is  
not saving in the table category\_users. Data to the table users is  
saving. What I have to do for storing data to category\_users? (more than  
one category for a single user).  
Please help.  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![indu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/eada6e/32.png) [@indu](https://www.ruby-forum.com/u/indu)\
**Post date:** [March 19, 2009, 7:59am UTC](https://www.ruby-forum.com/t/two-models-with-restful-authentication/163318/2 "2009-03-19T07:59:50Z")

</div>

Try to load up script/console, and check if user.category\_ids=  
[1,3,6,…] works …

On 19. Mar., 07:38 h., Indu RS [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![indu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/eada6e/32.png) [@indu](https://www.ruby-forum.com/u/indu)\
**Post date:** [March 19, 2009, 8:07am UTC](https://www.ruby-forum.com/t/two-models-with-restful-authentication/163318/3 "2009-03-19T08:07:19Z")

</div>

Vojto wrote:

> Try to load up script/console, and check if user.category\_ids=  
> [1,3,6,…] works …
> 
> On 19. Mar., 07:38 h., Indu RS [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> Thanks for the immediate reply.

Solve the issue by adding attr\_accessible :category\_ids in the model.  
But another error is coming ie  
undefined method `to\_sym’ for #State:0x665cc04  
installed the plugin with --include-activation and --stateful options.  
I dont’ understand the reason for that. Pls help.  
Any suggestions for a good documentation of using the  
restful\_authentication plugin?

---

<div class="post-metadata">

**Author:** ![indu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/eada6e/32.png) [@indu](https://www.ruby-forum.com/u/indu)\
**Post date:** [March 19, 2009, 8:58pm UTC](https://www.ruby-forum.com/t/two-models-with-restful-authentication/163318/4 "2009-03-19T20:58:59Z")

</div>

Give us the context of where the error is getting raised.

On 19. Mar., 08:07 h., Indu RS [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
