Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Nondeterministic behavior causing asset pipeline problems? #49

Closed
alexfarrill opened this Issue · 5 comments

2 participants

@alexfarrill

Hi, I'm seeing a problem while including js-routes in the asset pipeline in a Rails 3.2.3. We have two app servers which are precompiling assets. The signatures do not match between the compiled js on the two app servers and it looks like there is a difference in the order of the named routes that are being generated in the compiled javascript. I haven't looked too deeply into the code yet, but is it possible that this is a bug? I will investigate further tomorrow morning, but please point me in the right direction if this sounds possible.
Thanks,
Alex

@alexfarrill

It seems to me that the problem is that Rails.application.routes.named_routes.routes is a Hash and so no order is implied. Would it be reasonable to sort this, e.g. in alphabetical order by key name, when it is needed?
Thanks
Alex

@bogdan
Collaborator

Yes, seems reasonable.

Btw are you using 1.8 or 1.9? This can make a big difference in how Hash works.

@alexfarrill
@bogdan
Collaborator

So, all you need is add sort call at this line:
https://github.com/railsware/js-routes/blob/master/lib/js_routes.rb#L111

    js_routes = Rails.application.routes.named_routes.routes.sort.map do |_, route|

I don't want to commit this to master until make sure it fixes your problem
Please try it on your side

@bogdan
Collaborator

So, all you need is add sort call at this line:
https://github.com/railsware/js-routes/blob/master/lib/js_routes.rb#L111

    js_routes = Rails.application.routes.named_routes.routes.sort.map do |_, route|

I don't want to commit this to master until make sure it fixes your problem
Please try it on your side

@bogdan bogdan closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.