# Hidden\_field with nested attributes problem

**URL:** <https://www.ruby-forum.com/t/hidden-field-with-nested-attributes-problem/172998>\
**Category:** Rails\
**Created:** [July 31, 2009, 1:24am UTC](https://www.ruby-forum.com/t/hidden-field-with-nested-attributes-problem/172998 "2009-07-31T01:24:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bob\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5e9695/32.png) [@Bob\_O](https://www.ruby-forum.com/u/Bob_O)\
**Post date:** [July 31, 2009, 1:24am UTC](https://www.ruby-forum.com/t/hidden-field-with-nested-attributes-problem/172998/1 "2009-07-31T01:24:34Z")

</div>

ive been able to get nested attributes to work before. but only with a  
has\_many  
Im having problems with hidden fields and nested attributes

model - owner.rb

belongs\_to :ticket  
belongs\_to :employee

model - ticket.rb

belongs\_to :owner, :class =\> ‘Owner’  
accepts\_nested\_attributes\_for :owner, :allow\_destroy =\> true

controller - tickets\_controller.rb  
def new  
@ticket = Ticket.new  
@ticket.owner.build  
respond\_to do |format|  
format.html # new.html.erb  
format.xml { render :xml =\> @ticket }  
end  
end

tickets view - new.html.erb  
\<% form\_for(@ticket) do |f| %\>  
\<%= f.error\_messages %\>

\<%= f.label :subject %\>  
 \<%= f.text\_field :subject %\>

\<%= f.label :description %\>  
 \<%= f.text\_area :description, :rows =\> 10, :cols =\> 48 %\>

\<%= f.label :due\_date %\>  
 \<%= f.text\_field :due\_date, :id =\> 'ticket\_date\_select' %\>

\<%= f.label :ticket\_status\_id, "Set Ticket Status" %\>  
 \<%= collection\_select(:ticket, :ticket\_status\_id, TicketStatus.all, :id, :status\_type)%\>

\<%= f.label :priority\_id, "Ticket Priority" %\>  
 \<%= collection\_select(:ticket, :priority\_id, Priority.all, :id, :priority\_type)%\>

 \<% f.fields\_for :owner do |owner\_form|%\> \<%= owner\_form.hidden\_field :ticket\_id, :value =\> @ticket.id %\> \<%= owner\_form.hidden\_field :employee\_id, :value =\> current\_employee.id %\> \<% end %\> 

\<%= f.submit 'Create' %\>

\<% end %\>

Basically im trying to set the ticket\_id and employee\_id in the owner  
join model.

any help on what im doing wrong?
