dnagir / knockout-rails

KnockoutJS for Rails with Sweetness
96 stars 16 forks source link

Opinionated collectionUrl #5

Closed erikreedstrom closed 9 years ago

erikreedstrom commented 12 years ago

The collection url generated by the getURL method is too opinionated about the pluralization rules associated with a model. Currently, the method appends "s" to the persisted model, however, this means that for a collection of "countries" the associated code would read: @persistAt 'countrie'

This obviously is confusing and factually incorrect. I suggest removing the appended "s".

dnagir commented 12 years ago

Yeah, that makes sense. I took this part from Spinejs.

I think using plural always is a better way to go (so there's no guessing).

But in the meanwhile you can just use this:

class User extends ko.Model
  @getUrl = -> 'countries'

I think modifying persistAt to accept plural string or a function is a better way to go. I'll keep this open until I'll have time to update it (or you can submit a PR with a spec).