Topic: ActiveResource and Carrierwave

Hello,

I am currently playing with a little rails application that uses carrierwave for uploading files. I was trying to write a CLI client that is able to communicate with my rails application - using RestClient this worked fine so far.

Then I discovered ActiveResource which seems to be much easier to use concerning "normal" model attributes. However, I do not make it to upload files to the server as if I was using the web interface.

I already hat a look at Carrierwave with ActiveResource but this did not really help me. Although, I do not get any error messages anymore it does not upload the file (the according field just stays empty and nothing is saved on the hard disk).

Here is my code in which I wish to integrate:
the model on the server

class Datum
  include Mongoid::Document
  field :name, type: String
#  field :path, type: String # for path validation
  field :size, type: Float

  attr_accessible :name, :path

  #  validates :name, :path, :presence => true

  mount_uploader(:path, DataUploader)
end

the client code to create a new "datum"

class WaveClient < Thor

  desc "new", "upload a new file"
  method_option :name, :aliases => "-n", :desc => "the name of the file"
  method_option :file, :aliases => "-f", :desc => "the path to the file"

  def new
    # get name and path
    name = ask("Please provide a name for the file:") unless (name = options[:name])
    path = ask("Please provide the location of the file:") unless (path = options[:file])

    # create new datum
    res = Datum.new(name: name, size: 42)
    res.path = File.open("#{path}")
    res.save!
  end

As error I get the 500 internal server error what does not really help.

Excuse me for the code style. I am pretty new to ruby on rails and trying a bit for myself, even though I hope that you can help me a bit wink