Hidden_field with nested attributes problem

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?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs