Skip to content

Api changes in version 3

Nick Palaniuk edited this page May 9, 2016 · 29 revisions

Plurals

-v 2.x

class Controller
  expose(:person)
end

-v 3.x

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 options

expose(name, options = {}, &block)

-v 2.x

  • 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

-v 3.x

  • Possible options
:fetch
:id
:find
:build
:build_params
:scope
:model
:decorate
  • Use :from in place of :ancestor
  • Use :build_params in place of :params

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