I'm using the Paperclip gem and act_as_api gem to configure my API. I have a attribute called image in Product model
When using act_as_api with the following definition:
class Product < ActiveRecord::Base
...
acts_as_api
api_accessible :public do |t|
t.add :id
t.add :name
t.add :price
t.add :image
end
....
How can I decide how to set the image size like (:medium, :thumb etc) which paperclip provides in the api template?
You can pass a lambda to the add
call like this:
t.add lambda{|product| product.image.url(:medium) }, :as => :image
More information can be found in the wiki of the repo: https://github.com/fabrik42/acts_as_api/wiki/Calling-a-lambda-in-the-api-template