Skip to content

Commit 7d2c4a1

Browse files
mansonasivakumar-kailasam
authored andcommitted
Use a new example for irregular words
1 parent 6f6ab3c commit 7d2c4a1

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

guides/v3.1.0/models/customizing-adapters.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ Data comes bundled with
108108
ActiveSupport::Inflector compatible library for inflecting words
109109
between plural and singular forms. Irregular or uncountable
110110
pluralizations can be specified via `Ember.Inflector.inflector`.
111-
A common way to do this is:
111+
To do this, create a file containing your customizations and import it
112+
in `app.js`:
112113

113114
```javascript {data-filename=app/app.js}
114115
// sets up Ember.Inflector
@@ -120,16 +121,20 @@ import Inflector from 'ember-inflector';
120121

121122
const inflector = Inflector.inflector;
122123

123-
inflector.irregular('formula', 'formulae');
124+
// Tell the inflector that the plural of "campus" is "campuses"
125+
inflector.irregular('campus', 'campuses');
126+
127+
// Tell the inflector that the plural of "advice" is "advice"
124128
inflector.uncountable('advice');
125129

126-
// Meet Ember Inspector's expectation of an export
130+
// Modules must have an export, so we just export an empty object here
127131
export default {};
128132
```
129133

130-
This will tell the JSON API adapter that requests for `formula`
131-
should go to `/formulae/1` instead of `/formulas/1`, and that
132-
requests for `advice` should go to `/advice/1` instead of `/advices/1`.
134+
The JSON API adapter will now make requests for `Campus` models to
135+
`/campuses` and `/campuses/1` (instead of `/campus/` and `/campus/1`),
136+
and requests for `advice` to `/advice` and `/advice/1` (instead of
137+
`/advices/` and `/advices/1`).
133138

134139
When specifying irregular inflection rules for compound words, only the final word or phrase should be specified. For example, to specify the plural of `redCow` as `redKine` or `red-cow` as `red-kine`, only the final word segments `cow` and `kine` should be specified:
135140

0 commit comments

Comments
 (0)