Type:
Class

ActiveModel is a class to be implemented by each ORM to allow Rails to generate customized controller code.

The API has the same methods as ActiveRecord, but each method returns a string that matches the ORM API.

For example:

ActiveRecord::Generators::ActiveModel.find(Foo, "params[:id]")
# => "Foo.find(params[:id])"

DataMapper::Generators::ActiveModel.find(Foo, "params[:id]")
# => "Foo.get(params[:id])"

On initialization, the ActiveModel accepts the instance name that will receive the calls:

builder = ActiveRecord::Generators::ActiveModel.new "@foo"
builder.save # => "@foo.save"

The only exception in ActiveModel for ActiveRecord is the use of self.build instead of self.new.

all

all(klass) Class Public methods GET index

2015-06-20 00:00:00
save

save() Instance Public methods POST create

2015-06-20 00:00:00
errors

errors() Instance Public methods POST create PATCH/PUT update

2015-06-20 00:00:00
update

update(params=nil) Instance Public methods PATCH/PUT update

2015-06-20 00:00:00
find

find(klass, params=nil) Class Public methods GET show GET edit PATCH/PUT update

2015-06-20 00:00:00
destroy

destroy() Instance Public methods DELETE destroy

2015-06-20 00:00:00
new

new(name) Class Public methods

2015-06-20 00:00:00
build

build(klass, params=nil) Class Public methods GET new POST create

2015-06-20 00:00:00