leshill / handlebars_assets

Use handlebars.js templates with the Rails asset pipeline.
MIT License
647 stars 159 forks source link

Can someone explain this behaviour? #129

Closed wjdhamilton closed 1 year ago

wjdhamilton commented 9 years ago

This isn't really a bug as such, but it is rather confusing. In order to use rails helpers in my templates I added the following initialiser to my app:

Rails.application.assets.context_class.class_eval do
  include ActionView::Helpers
  include Rails.application.routes.url_helpers
end

...and now if I try and use the following template:

<label for="select-suppliers">Select Supplier:</label>
<%= select_tag "select-suppliers", options_from_collection_for_select(Supplier.all, "id", "name") %>
<% byebug %>
<div class="item_sets">
    {{> item_sets/_form }}
</div>

It only renders the list of suppliers if the call to byebug is included in the code. Why would this be? And can anyone recommend a better way of getting this functionality?

wjdhamilton commented 9 years ago

I should also add that the call to byebug is ignored, the code just continues right past

wjdhamilton commented 9 years ago

...and almost just as strangely byebug started to work and the template continues to work properly without it. Something to do with Spring?

AlexRiedler commented 9 years ago

sounds potentially like a caching issue (whether its static asset caching in the browser, or spring, or rails).