Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nondeterministic behavior causing asset pipeline problems? #49

Closed
alexfarrill opened this issue Jun 14, 2012 · 5 comments
Closed

Nondeterministic behavior causing asset pipeline problems? #49

alexfarrill opened this issue Jun 14, 2012 · 5 comments

Comments

@alexfarrill
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Collaborator

bogdan commented Jun 14, 2012

Yes, seems reasonable.

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

@alexfarrill
Copy link
Contributor Author

1.8.7

Alex

Sent from my iPhone

On Jun 14, 2012, at 3:12 AM, Bogdan Gusievreply@reply.github.com wrote:

Yes, seems reasonable.

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


Reply to this email directly or view it on GitHub:
#49 (comment)

@bogdan
Copy link
Collaborator

bogdan commented Jun 14, 2012

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

1 similar comment
@bogdan
Copy link
Collaborator

bogdan commented Jun 14, 2012

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants