# Pass the model type to the action via a hidden field?

**URL:** <https://www.ruby-forum.com/t/pass-the-model-type-to-the-action-via-a-hidden-field/123302>\
**Category:** Rails\
**Created:** [December 16, 2007, 5:16am UTC](https://www.ruby-forum.com/t/pass-the-model-type-to-the-action-via-a-hidden-field/123302 "2007-12-16T05:16:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![paradise](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8e7dd6/32.png) [@paradise](https://www.ruby-forum.com/u/paradise)\
**Post date:** [December 16, 2007, 5:16am UTC](https://www.ruby-forum.com/t/pass-the-model-type-to-the-action-via-a-hidden-field/123302/1 "2007-12-16T05:16:54Z")

</div>

I have a question about the acts\_as\_commentable plugin. In the  
instructions it says to use hidden fields to pass the model type and  
model id. This is somewhat confusing me. I am trying to add comments  
to a user object and am not sure how to specify the model type. This  
is the link that I am using to get the comment view where one will  
enter his/her comments:  
\<%= link\_to “add a comment”, :action =\> “add”, :controller =\>  
“comments”, :value =\> @user %\>

Do I pass an instance of the user object through the value=\>@user  
above?  
Here is my comments add page:  
\<% form\_for( :comment, :url =\> comments\_path ) do |f | -%\>  
\<%= f.text\_field :title %\>  
\<%= f.text\_field :comment %\>  
\<%= f.hidden\_field ‘commentable’, ‘commentable’, :value =\> @user %\>  
\<%= f.hidden\_field ‘commentable’, ‘commentable\_id’, :value =\>  
@user.id %\>  
\<%= submit\_tag ‘Create’ %\>  
\<% end -%\>

I know this is not correct, but I am very confused as to what the  
@model.type and @model.id should each be. If anyone can give me a  
lead as to the right direction it will be much appreciated! 🙂 thanks
