To keep your api templates DRY, you can create a new template based on another template of the same model.
class User < ActiveRecord::Base acts_as_api api_accessible :only_names do |t| t.add :first_name t.add :last_name end api_accessible :age_and_names, :extend => :only_names do |t| t.add :age end end
The api template age_and_names extends the template only_names so it will contain the attributes first_name, last_name and age.
age_and_names
only_names
first_name
last_name
age
It is also possible to remove attributes that were inherited from the api template.
class User < ActiveRecord::Base acts_as_api api_accessible :only_names do |t| t.add :first_name t.add :last_name end api_accessible :age_and_first_name, :extend => :only_names do |t| t.add :age t.remove :last_name end end
Now responses with the template age_and_first_name will contain the attributes first_name and age.
age_and_first_name
There was an error while loading. Please reload this page.