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

'app.config.assets.configure' is 'undefined' in 'handlebars_assets/engine.rb' #162

Closed
happyvig opened this issue Jun 6, 2018 · 6 comments

Comments

@happyvig
Copy link

happyvig commented Jun 6, 2018

What value should be configured in the (gem consuming) Rails (2.3) app's application.rb so that 'app.config.assets.configure' comes defined in engine.rb ?

@AlexRiedler
Copy link
Collaborator

AlexRiedler commented Jun 6, 2018

Rails 2.3 reached EOL on 2013-06-25; I would recommend updating your Rails application.

There might be an old version of handlebars_assets that would support that old version of Rails, but it is pretty unlikely since a lot changed between Rails 2.x and 3.x. I would personally not recommend going this path.

@happyvig
Copy link
Author

happyvig commented Jun 7, 2018

Apologies. My mistake. My Rails version is 3.2.22.5

Any specific 'Sprockets' gem version to be used ?

I am using "sprockets" --> "2.2.3" & "turbo-sprockets-rails3" --> "0.3.14"

One quick note :
I dont use '/app/assets/javascripts' folder. Instead I put all my javascripts & hbs templates folder inside '/public' folder. I haven't tried deploying this code to my server yet. Do you foresee any errors in this folder structure approach ?

I created an initializer called handlerbars_init.rb to update the 'path_prefix' config value :

HandlebarsAssets.configure do |config|
config.template_namespace = 'HandlebarsTemplates'
config.path_prefix = '/public/javascripts/templates'
end

@AlexRiedler
Copy link
Collaborator

@happyvig I would not recommend doing this in public; there is a reason public is different then app/assets/javascripts ; generally using rails and going against convention will be bad news.

the public folder is used for static assets POST compilation; by putting your assets in the folder you may have conflict; and access to public files will be available in most environments (exposed to public).

@happyvig
Copy link
Author

happyvig commented Jun 8, 2018

True. Valid point there.

Question 1 :
Any specific 'Sprockets' gem version to be used when using 'handlebars_assets' v0.23.2 gem ?
I am using "sprockets" --> "2.2.3" & "turbo-sprockets-rails3" --> "0.3.14"

Question 2 :
And also template namespace override is not working when specified via an initializer as

HandlebarsAssets.configure do |config|
    config.template_namespace = 'HandlebarsTemplates'
    config.path_prefix = '/public/javascripts/templates'
end

or by specifying inside config/application.rb as
HandlebarsAssets::Config.template_namespace = "HBS"

Appreciate your thoughts about this.

@AlexRiedler
Copy link
Collaborator

Q1. not that I am aware of; last time I was running with sprockets 3 I believe (its been a long time)

Q2. not sure how that could be happen, and I don't really have time to debug; most of the code is at: https://github.com/leshill/handlebars_assets/blob/master/lib/handlebars_assets/handlebars_template.rb and I believe everywhere is correct for use of template namespace.

@happyvig
Copy link
Author

happyvig commented Jun 9, 2018

Thank you.
I have figured out that the latest version of the gem (0.23.2) is not working with Sprockets 2.x and that's why it was throwing ''app.config.assets.configure" as undefined for me.

I believe "app.config.assets.configure" gets defined in the Sprockets 3.x (not tested)

Since my app uses Sprockets 2.x currently, I am planning to use a lower version of the gem (0.20.2) which does not rely on 'app.config.assets.configure' method.

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