Skip to content

v0.5.0 - Associations Reworked to Relationships

Compare
Choose a tag to compare
@lgebhardt lgebhardt released this 16 Jul 21:18
· 999 commits to master since this release

Note: this release contains some breaking changes from earlier versions.

This release fixes the following issues:

  • Context is now correctly passed into the records_for_relation methods
  • Uses public_send instead of send to prevent inadvertent access level violations.
  • Errors now use the source instead of path parameter, as per the JSON API spec.
  • Resource linkage is no longer output by default.
  • Fixed issue with "to one" relationships that are backed by a belongs_to association on the model have been fixed. A new option foreign_key_on can now be set to related to indicate the location of the foreign key. This defaults to :self.

Change list:

  • Resource interrogates the model for the primary key in most instances. Readme has been corrected regarding using alternate primary keys.
  • Now supports engines. Generates the correct urls when run as an engine.
  • New configuration and relationship option to include resource linkage.
  • Internally Associations have been renamed to Relationships.
  • New relationship
  • Has One has been renamed to To One.
  • Has many has been renamed to To Many.

The following resource callbacks have been renamed:

  • create_has_many_link => create_to_many_link
  • replace_has_many_links => replace_to_many_links
  • create_has_one_link => create_to_one_link
  • replace_has_one_link => replace_to_one_link
  • replace_polymorphic_has_one_link => replace_polymorphic_to_one_link
  • remove_has_many_link => remove_to_many_link
  • remove_has_one_link => remove_to_one_link

Resource methods that reference associations have been renamed to reference relationships. Methods the reference "has one" have been renamed to "to one". Methods the reference "has many" have been renamed to "to many". The following resource methods are designed to be overridden. The following name changes have been made:

  • verify_association_filter => verify_relationship_filter
  • _updatable_associations => _updatable_relationships