librelist archives

« back to archive

Nesta & Sinatra Extensions

Nesta & Sinatra Extensions

From:
torrancew
Date:
2012-03-23 @ 05:23
Is it possible to extend Nesta with Sinatra extensions? In this case, I'm
attempting to add Sinatra AssetPack
(http://ricostacruz.com/sinatra-assetpack/)

When adding the require to app.rb, I'm receiving:

  ERROR -- : undefined method `register' for Sinatra:Module (NoMethodError)
  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/sinatra-assetpack-0.0.11/lib/sinatra/assetpack.rb:60:in
`<module:Sinatra>'
  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/sinatra-assetpack-0.0.11/lib/sinatra/assetpack.rb:3:in
`<top (required)>'
  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:68:in
`require'
  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:68:in
`block (2 levels) in require'
  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:66:in
`each'
  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:66:in
`block in require'
  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in
`each'
  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in
`require'
  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler.rb:119:in
`require'
  config.ru:5:in `block in <main>'
  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/rack-1.4.1/lib/rack/builder.rb:51:in
`instance_eval'
  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/rack-1.4.1/lib/rack/builder.rb:51:in
`initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  ...

Thanks,
-- 
torrancew

Re: [nesta] Nesta & Sinatra Extensions

From:
Graham Ashton
Date:
2012-03-23 @ 08:41
Can you show us your code? If you haven't, you'll need to do call register
inside the Nesta::App class. 

On 23 Mar 2012, at 05:23, torrancew <nestaman@warrentorrance.com> wrote:

> Is it possible to extend Nesta with Sinatra extensions? In this case, I'm
> attempting to add Sinatra AssetPack
> (http://ricostacruz.com/sinatra-assetpack/)
> 
> When adding the require to app.rb, I'm receiving:
> 
>  ERROR -- : undefined method `register' for Sinatra:Module (NoMethodError)
>  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/sinatra-assetpack-0.0.11/lib/sinatra/assetpack.rb:60:in
`<module:Sinatra>'
>  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/sinatra-assetpack-0.0.11/lib/sinatra/assetpack.rb:3:in
`<top (required)>'
>  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:68:in
`require'
>  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:68:in
`block (2 levels) in require'
>  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:66:in
`each'
>  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:66:in
`block in require'
>  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in
`each'
>  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in
`require'
>  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler.rb:119:in
`require'
>  config.ru:5:in `block in <main>'
>  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/rack-1.4.1/lib/rack/builder.rb:51:in
`instance_eval'
>  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/rack-1.4.1/lib/rack/builder.rb:51:in
`initialize'
>  config.ru:1:in `new'
>  config.ru:1:in `<main>'
>  ...
> 
> Thanks,
> -- 
> torrancew
> 
> 

Re: [nesta] Nesta & Sinatra Extensions

From:
torrancew
Date:
2012-03-26 @ 00:58
Code is available at

https://github.com/torrancew/nesta-experiments

All related work is contained in the most recent commit.

Thanks,
-- 
torrancew

On Fri, Mar 23, 2012 at 08:41:23AM +0000, Graham Ashton wrote:
> Can you show us your code? If you haven't, you'll need to do call 
register inside the Nesta::App class. 
> 
> On 23 Mar 2012, at 05:23, torrancew <nestaman@warrentorrance.com> wrote:
> 
> > Is it possible to extend Nesta with Sinatra extensions? In this case, I'm
> > attempting to add Sinatra AssetPack
> > (http://ricostacruz.com/sinatra-assetpack/)
> > 
> > When adding the require to app.rb, I'm receiving:
> > 
> >  ERROR -- : undefined method `register' for Sinatra:Module (NoMethodError)
> >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/sinatra-assetpack-0.0.11/lib/sinatra/assetpack.rb:60:in
`<module:Sinatra>'
> >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/sinatra-assetpack-0.0.11/lib/sinatra/assetpack.rb:3:in
`<top (required)>'
> >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:68:in
`require'
> >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:68:in
`block (2 levels) in require'
> >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:66:in
`each'
> >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:66:in
`block in require'
> >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in
`each'
> >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in
`require'
> >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler.rb:119:in
`require'
> >  config.ru:5:in `block in <main>'
> >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/rack-1.4.1/lib/rack/builder.rb:51:in
`instance_eval'
> >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/rack-1.4.1/lib/rack/builder.rb:51:in
`initialize'
> >  config.ru:1:in `new'
> >  config.ru:1:in `<main>'
> >  ...
> > 
> > Thanks,
> > -- 
> > torrancew
> > 
> > 
> 

Re: [nesta] Nesta & Sinatra Extensions

From:
torrancew
Date:
2012-03-26 @ 01:19
I think I may have traced this error to the Sinatra extension in question,
but am not sure. It seems that lib/sinatra/assetpack.rb does not explicitly
require any sinatra classes anywhere, and is failing on an implicit
register called at the end of that file. Adding a "require 'sinatra/base'"
in that file locally solved the issue on my side, but as I'm a bit new to
the Sinatra world, I'm wondering if this is an actual upstream flaw, or
misuse of Sinatra/Nesta on my side.

Any advice is appreciated.

Thanks,
-- 
torrancew

On Sun, Mar 25, 2012 at 05:58:02PM -0700, torrancew wrote:
> Code is available at
> 
> https://github.com/torrancew/nesta-experiments
> 
> All related work is contained in the most recent commit.
> 
> Thanks,
> -- 
> torrancew
> 
> On Fri, Mar 23, 2012 at 08:41:23AM +0000, Graham Ashton wrote:
> > Can you show us your code? If you haven't, you'll need to do call 
register inside the Nesta::App class. 
> > 
> > On 23 Mar 2012, at 05:23, torrancew <nestaman@warrentorrance.com> wrote:
> > 
> > > Is it possible to extend Nesta with Sinatra extensions? In this case, I'm
> > > attempting to add Sinatra AssetPack
> > > (http://ricostacruz.com/sinatra-assetpack/)
> > > 
> > > When adding the require to app.rb, I'm receiving:
> > > 
> > >  ERROR -- : undefined method `register' for Sinatra:Module (NoMethodError)
> > >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/sinatra-assetpack-0.0.11/lib/sinatra/assetpack.rb:60:in
`<module:Sinatra>'
> > >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/sinatra-assetpack-0.0.11/lib/sinatra/assetpack.rb:3:in
`<top (required)>'
> > >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:68:in
`require'
> > >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:68:in
`block (2 levels) in require'
> > >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:66:in
`each'
> > >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:66:in
`block in require'
> > >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in
`each'
> > >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in
`require'
> > >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/bundler-1.1.1/lib/bundler.rb:119:in
`require'
> > >  config.ru:5:in `block in <main>'
> > >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/rack-1.4.1/lib/rack/builder.rb:51:in
`instance_eval'
> > >  
/usr/local/rvm/gems/ruby-1.9.3-p0@tblog/gems/rack-1.4.1/lib/rack/builder.rb:51:in
`initialize'
> > >  config.ru:1:in `new'
> > >  config.ru:1:in `<main>'
> > >  ...
> > > 
> > > Thanks,
> > > -- 
> > > torrancew
> > > 
> > > 
> > 
> 

Re: [nesta] Nesta & Sinatra Extensions

From:
Graham Ashton
Date:
2012-03-26 @ 15:10
On 26 Mar 2012, at 02:19, torrancew wrote:

> Adding a "require 'sinatra/base'"
> in that file locally solved the issue on my side, but as I'm a bit new to
> the Sinatra world, I'm wondering if this is an actual upstream flaw, or
> misuse of Sinatra/Nesta on my side.
> 
> Any advice is appreciated.

If you're using Bundler then Sinatra should have been automatically 
required when you launched Nesta. Are you running your site (in 
development) with `bundle exec shotgun config.ru`, or something similar?