rstacruz / sinatra-assetpack

Package your assets transparently in Sinatra.
http://ricostacruz.com/sinatra-assetpack/
MIT License
541 stars 97 forks source link

Failed at "register Sinatra::AssetPack" #44

Closed Bastes closed 12 years ago

Bastes commented 12 years ago

The following code :

class App < Sinatra::Base register Sinatra::AssetPack ... end

Failed with the following message : sinatra-assetpack-0.0.11/lib/sinatra/assetpack.rb:60:in <module:Sinatra>': undefined methodregister' for Sinatra:Module (NoMethodError)

I tried with Sinatra 1.3.2 and sinatra-assetpack 0.0.11

aterris commented 12 years ago

If you are still struggling with this, make sure that Bundler.require is below require 'sinatra/base' in your config.ru

Bastes commented 12 years ago

Yep, all is working fine now. Thanks.

lessless commented 11 years ago

should I do the same for Padrino application?

j15e commented 11 years ago

@dirty-hippie No, padrino manage itself the sinatra requirements, you only have to register & configure assetpack. Are you having any issues?

Exemple :

class App < Padrino::Application
  register Padrino::Rendering
  register Padrino::Helpers
  register Sinatra::AssetPack

  set :root, File.dirname(__FILE__)

  assets {
    serve '/public',     from: 'assets/public'
    serve '/js',     from: 'assets/js'
    serve '/css',    from: 'assets/css'
    serve '/img', from: 'assets/img'

    # The second parameter defines where the compressed version will be served.
    # (Note: that parameter is optional, AssetPack will figure it out.)
    js :app, '/js/app.js', [
      '/js/vendor/jquery-1.8.3.min.js',
      '/js/vendor/jquery.colorbox-min.js',
      '/js/vendor/swfobject.js',
      '/js/polyfills.js',
      '/js/main.js'
    ]

    js :ltie9, '/js/ltie9.js', [
      '/js/vendor/html5shiv.js',
      '/js/vendor/respond.min.js'
    ]

    css :app, '/css/application.css', [
      '/css/vendor/colorbox.css',
      '/css/styles.css'
    ]

    js_compression  :jsmin      # Optional
    css_compression :simple       # Optional
  }
end