Search code examples
ruby-on-railsruby-on-rails-3soapsavon

ruby rails - save method


I created a data model, I am using mysql database. I use savon for handling SOAP requests. On the console I can see SOAP controller debug creating data. Most of the part of part of is working, expect saving the created information.

How do I bring in the save method? I want to save the successfully received response from a soap request. The actual code is big, so trying skip posting it here. I will post if required.

rails g model ticket ticket_num:string t_status:string priority:string solution:string  misc:string
rails generate controller ticket create
rake db:migrate

Controller Code:

class TicketController < ApplicationController
  def create
    ticket = Ticket.createticket(params[:caller], current_user.user_id, current_user.firstname, current_user.lastname, current_user.email)
    ticket.save
  end
end

Error Message:

NoMethodError in TicketController#create

undefined method `save' for #<Savon::SOAP::Response:0xaed6da4>

Solution

  • It's hard to tell without seeing the code, but I'm guessing the problem is that you're not returning your newly created Ticket object at the end of your Ticket.createticket method. You're probably doing something with your Savon client on the last line of the method so it's returning that instead of the new Ticket object.