I have a page which renders several partials; on my local mac everything is fine but after I push to heroku and visit the page the order of the partials is different!
I render partials with the code below and thought I controlled the order with a file naming convention.
html.erb:
<% Dir["app/views/partials/ws/*.html.erb"].each do |ws| %>
<%= render 'partials/ws/' + File.basename(ws,'.html.erb').slice(1..-1) %>
<% end %>
The partials use a naming convention:
_ws_01-why.html.erb
_ws_02-what.html.erb
_ws_03-who.html.erb
_ws_04-where.html.erb
_ws_05-when1.html.erb
_ws_06-how.html.erb
Heroku renders in this order:
_ws_01-why.html.erb
_ws_02-what.html.erb
_ws_06-how.html.erb
_ws_04-where.html.erb
_ws_05-when1.html.erb
_ws_03-who.html.erb
I’m not sure how heroku is interpreting the naming convention / ruby loop order… Wondering if there is a better naming convection or logic to add in my loop to control the order?
Thanks!
Change this:
to this:
You cannot be sure than an enumerator will choose the same order in all cases unless you force it somehow.