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.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?