TicketType(#70316537311800) expected, got String(#10085740)
app/controllers/reasons_controller.rb:44:in new' app/controllers/reasons_controller.rb:44:in
create’
View:
<%= f.label :ticket_type %>
<%= f.select :ticket_type, TicketType.all.collect {|t| [ t.description,
t.description]}, {:include_blank => “Please select one”}, :method =>
‘get’%>
Controller:
@reason = Reason.new(params[:reason])
respond_to do |format|
if @reason.save
format.html { redirect_to manage_tickets_path, notice: ‘Reason
was successfully created.’ }
etc
Model:
class Reason < ActiveRecord::Base
validates :description, :ticket_type, :presence => true
attr_accessible :description, :ticket_type
belongs_to :ticket_type, :foreign_key => :ticket_type
end
class TicketType < ActiveRecord::Base
attr_accessible :description
has_many :reasons, :foreign_key => :ticket_type
end
I have read the “Kitchen” posting about the same error, the only problem
is i am using a description, not ID.
Changing the form just gives errors, any help would be greatly
appreciated.
Thanks!