-
Notifications
You must be signed in to change notification settings - Fork 109
Api changes in version 3
Vinicius Ferreira Negrisolo edited this page May 9, 2016
·
29 revisions
class Controller
expose(:person)
end
In version 3 plural helpers are not automatically generated. Now collections must be explicitly exposed.
class Controller
expose(:people, -> { Person.all })
expose(:person)
end
expose(name, options={}, &block)
- Possible options
:ancestor
another exposure to scope from
:model
model to use for that exposure
:params
method to call on the controller to get a params hash
:finder
method used to find the record
:finder_parameter
attribute containing the finder method's unique identifier
- Use
:from
in place of:ancestor
- Use
:build_params
in place of:params
- Use
:id
instead of:finder_parameter
Instead of using :finder
and :finder_parameter
like this:
class PeopleController < ApplicationController
expose(:people, finder: :find_by_slug, finder_parameter: :slug)
end
This is now equivalent to:
class PeopleController < ApplicationController
expose :people, find_by: :slug, id: :slug
end