Skip to content

Api changes in version 3

Vinicius Ferreira Negrisolo 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

-v 2.x

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

-v 3.x

  • 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