Em 01-06-2012 13:20, Jeremy Walker escreveu:


On 1 June 2012 17:10, Steve Schwartz <[email protected] <mailto:[email protected]>> wrote:

    tl;dr;
    Hook into routes.rb while compiling CoffeeScript to Javascript
    and enable native feeling routes in CoffeeScript.

    I think the problem there is that you wouldn't know to put "1" in
    there at asset compile time. It'd only work for un-nested
    collection paths like "/products".


But in the CoffeeScript, the developer will know the id of the resource they're calling.

So, the CS:
$.get project_path(project.id <http://project.id>)

...could be pre-processed, using a lookup in routes.rb, into:
$.get "projects/#{project.id <http://project.id>}"

...which then gets compiled to:
$.get "projects/" + project.id <http://project.id>

And voila, you have a working solution. Am I missing something? :)


Yes, the id will be inside a JS variable. So if you have some constraints like /\d+/, it won't be able to check them...

--
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to