{"action":"created","issue":{"url":"https://api.github.com/repos/leshill/handlebars_assets/issues/145","labels_url":"https://api.github.com/repos/leshill/handlebars_assets/issues/145/labels{/name}","comments_url":"https://api.github.com/repos/leshill/handlebars_assets/issues/145/comments","events_url":"https://api.github.com/repos/leshill/handlebars_assets/issues/145/events","html_url":"https://github.com/leshill/handlebars_assets/issues/145","id":122896499,"number":145,"title":"\"undefined method `register_engine' for nil\" error when using `sprockets-rails` 3","user":{"login":"tjgrathwell","id":1041691,"avatar_url":"https://avatars.githubusercontent.com/u/1041691?v=3","gravatar_id":"","url":"https://api.github.com/users/tjgrathwell","html_url":"https://github.com/tjgrathwell","followers_url":"https://api.github.com/users/tjgrathwell/followers","following_url":"https://api.github.com/users/tjgrathwell/following{/other_user}","gists_url":"https://api.github.com/users/tjgrathwell/gists{/gist_id}","starred_url":"https://api.github.com/users/tjgrathwell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjgrathwell/subscriptions","organizations_url":"https://api.github.com/users/tjgrathwell/orgs","repos_url":"https://api.github.com/users/tjgrathwell/repos","events_url":"https://api.github.com/users/tjgrathwell/events{/privacy}","received_events_url":"https://api.github.com/users/tjgrathwell/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2015-12-18T07:27:26Z","updated_at":"2016-01-27T11:30:02Z","closed_at":"2016-01-27T06:46:48Z","body":"sprockets-rails 3 was just released, and apparently `app.assets` is now nil at initializer-time, so `app.assets.register_engine` won't work.\r\n\r\nOne possible solution is to use `config.assets.configure do |env|` instead, which seems to be the more 'proper' way:\r\n\r\n```diff\r\ndiff --git a/lib/handlebars_assets/engine.rb b/lib/handlebars_assets/engine.rb\r\nindex 8a4be6e..c219840 100644\r\n--- a/lib/handlebars_assets/engine.rb\r\n+++ b/lib/handlebars_assets/engine.rb\r\n@@ -2,8 +2,10 @@ module HandlebarsAssets\r\n   # NOTE: must be an engine because we are including assets in the gem\r\n   class Engine < ::Rails::Engine\r\n     initializer \"handlebars_assets.assets.register\", :group => :all do |app|\r\n-      ::HandlebarsAssets::register_extensions(app.assets)\r\n-      app.assets.version += \"#{::HandlebarsAssets::VERSION}\"\r\n+      config.assets.configure do |env|\r\n+        ::HandlebarsAssets::register_extensions(env)\r\n+        app.assets.version += \"#{::HandlebarsAssets::VERSION}\"\r\n+      end\r\n     end\r\n   end\r\n end\r\n```\r\n\r\nAnother solution is to use the new `register_transformer` code from https://github.com/leshill/handlebars_assets/pull/135 but relax the constraint on `Sprockets::VERSION` so it also applies to Sprockets 3. The `register_transformer` syntax should work in Sprockets 3 and up, and that code will be needed for Sprockets 4 anyway.\r\n\r\nRelated issue in the sprockets-rails repo: https://github.com/rails/sprockets-rails/issues/237"},"comment":{"url":"https://api.github.com/repos/leshill/handlebars_assets/issues/comments/175570287","html_url":"https://github.com/leshill/handlebars_assets/issues/145#issuecomment-175570287","issue_url":"https://api.github.com/repos/leshill/handlebars_assets/issues/145","id":175570287,"user":{"login":"tagliala","id":556268,"avatar_url":"https://avatars.githubusercontent.com/u/556268?v=3","gravatar_id":"","url":"https://api.github.com/users/tagliala","html_url":"https://github.com/tagliala","followers_url":"https://api.github.com/users/tagliala/followers","following_url":"https://api.github.com/users/tagliala/following{/other_user}","gists_url":"https://api.github.com/users/tagliala/gists{/gist_id}","starred_url":"https://api.github.com/users/tagliala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tagliala/subscriptions","organizations_url":"https://api.github.com/users/tagliala/orgs","repos_url":"https://api.github.com/users/tagliala/repos","events_url":"https://api.github.com/users/tagliala/events{/privacy}","received_events_url":"https://api.github.com/users/tagliala/received_events","type":"User","site_admin":false},"created_at":"2016-01-27T11:30:02Z","updated_at":"2016-01-27T11:30:02Z","body":"Thanks!"}}