Hello,

I have a problem with making a system call to a Java program via Rails. When I call it through controller it doesn't seem to work, but when I do the same thing in console it works perfectly.

There are two models Order and Payment (Order has one Payment). Payment model that has following method:

Code Ruby:
def transaction_register()
  output_raw = `java -jar #{JAR} #{MERCHANT} -a #{(self.amount*100).to_i.to_s} #{CURRENCY} #{self.ip_address}`
 
  output = YAML.parse output_raw
  # ...removed rest of the code...
end
It runs a Java program that should contact the payment gateway and return transaction information. It is called in controller like this (some code removed for clarity):

Code Ruby:
def save_order
  order = Order.new
  order.order_items << @cart.items
  order.payment = Payment.new
  order.payment.ip_address = request.env["REMOTE_ADDR"]
  order.payment.amount = order.total_cost
  order.payment.transaction_register
 
  # ...removed rest of the code...
end

The problem is that when this code is run through a controller it doesn't seem to execute, but when I do almost (I only fake ip_address) the same thing in console it works.

Does anyone has any ideas what might be the problem?

Thanks.