Displaying 2 results from an estimated 2 matches for "ticketcontrol".
Did you mean:
tickcontrol
2006 Apr 26
10
save new model with child model
Hi,
I am having a problem saving a new model that has an associated child
model. If a new ticket is being created and will have one comment to
go with it then I tried this in my action
@ticket = Ticket.new(params[:ticket])
@comment = Comment.new(params[:comment])
@ticket.comments << @comment
if @ticket.save
@notice = "Ticket added. Thanks for
2006 Mar 08
1
Nil Object Error
...ce.
ticket.rb
============
class Ticket < ActiveRecord::Base
belongs_to :agent
belongs_to :status
belongs_to :priority
belongs_to :category
validates_presence_of :employee_id, :date, :agent_id, :status_id,
:priority_id, :category_id, :summary
end
ticket_controller.rb
============
class TicketController < ApplicationController
layout "standard-layout"
scaffold :Ticket
def edit
@ticket = Ticket.find(params[:id])
@employees = Employee.find_all
@agents = Agent.find_all
@statuses = Status.find_all
@priorities = Priority.find_all
@categories = Category.find_all
end
d...