Skip to content
This repository

Calling a method of the model

You can easily add any method of a model and its return value to the an api template by just adding the method name as a symbol.

class User < ActiveRecord::Base

  acts_as_api

  api_accessible :only_full_name do |t|
    t.add :full_name
  end

  def full_name
    '' << first_name.to_s << ' ' << last_name.to_s
  end

end

Note: This will only work for public methods of the model.

Something went wrong with that request. Please try again.