Search code examples
ruby-on-rails-3spine.js

Spine.js & rails - Spine.js doesn't use plural form of model name for the routes


I am following the guide of integrating Spine.js with Rails 3.

I created a model Activity and follow the spine.js guide to try it out. When I tried to create an activity I got this error:

POST http://localhost:3000/activitys 404 (Not Found)

Clearly it's not pluralize the model name for the route, is it fixable from spine.js side?


Solution

  • You can specify the model's endpoint URL in Spine if the URL Spine guessed is not the correct one. Put the following inside your activity.js.coffee file:

        class App.Activity extends Spine.Model
            @url: '/activities'
    

    That should make Spine hit the proper endpoint.