xdotcommer
xdotcommer

Reputation: 793

How to have consistency between rails and javascript routes?

I was getting a little tired of seeing this sort of thing:

$('#events').load('/user/' + user.id + '/events?limit=' + limit);

Strewn throughout my code when I had nice rails routes like user_events_path(user) to use.

Upvotes: 1

Views: 37

Answers (1)

xdotcommer
xdotcommer

Reputation: 793

It turns out there's a nice plugin called js-routes that allows you to reuse your routes like this:

Routes.user_events_path({user_id: user.id})

Upvotes: 1

Related Questions