Merb

16 views
Skip to first unread message

kevwil

unread,
Jan 3, 2008, 10:47:12 PM1/3/08
to thin-ruby
I'm really into Merb these days - can I use Thin with Merb?

macournoyer

unread,
Jan 3, 2008, 11:02:10 PM1/3/08
to thin-ruby
Hi Kevin,

Sure, Merb already support Rack. But the sad thing is there's a lot of
hardcoded stuff in the merb script.
So to use it with thin you can create a config.ru file with this in
it:

======= config.ru =======
ENV['MERB_ENV'] = 'production'
require 'rubygems'
require 'rack'
require 'merb'
require 'thin'

Merb::Server.instance_eval { @@merb_raw_opts = [] }
Merb::Server.merb_config
Merb::Server.initialize_merb

run Merb::Rack::Adapter.new
=====================

then run it with: rackup -s thin

mattman

unread,
Jan 4, 2008, 12:35:31 AM1/4/08
to thin-ruby
With that code and the router.rb file (below), I'm getting 404's on
stylesheets and javascript

===== router.rb =====
Merb::Router.prepare do |r|
# RESTful routes
r.match(%r[^/stocks/([^/]+)/([^/\.]+)(\.(.+))?$]).to(
:controller => "stocks",
:action => "show",
:exchange => "[1]",
:code => "[2]",
:format => "[4]"
)

r.match('/').to(:controller => 'stocks', :action =>'index')

r.default_routes
end
=================

macournoyer

unread,
Jan 4, 2008, 9:09:01 AM1/4/08
to thin-ruby
That is weird. Doesn't even work with webrick (merb -w) that also uses
the Rack adapter.

macournoyer

unread,
Jan 4, 2008, 9:13:07 AM1/4/08
to thin-ruby
Looks like Merb rack adapters don't serve static files.

Change the last line in the config.ru file:

run Rack::Cascade.new([Merb::Rack::Adapter.new,
Rack::File.new('public')])

Let me know if that fixes it!

On Jan 4, 12:35 am, mattman <matt...@gmail.com> wrote:

Martin

unread,
Jan 16, 2008, 11:02:13 PM1/16/08
to thin-ruby
This is not working with Merb version 0.5.2 as some of those methods
are not longer there. (Merb::Server.merb_config) is one of them.
L8er - Martin

Kevin Williams

unread,
Jan 17, 2008, 12:18:40 AM1/17/08
to thin...@googlegroups.com
There was some refactoring done in Merb after 0.5.0, which broke this.
Now, Merb is developing merb_core based around Rack instead of
directly against Mongrel, so thin will be supported in the next
Merb(_core??) release.

http://github.com/wycats/merb-core/tree/master

Just hang in there until Merb 0.9 in a few weeks. For now I suggest
sticking with evented mongrel.

On Jan 16, 2008 9:02 PM, Martin <martin...@gmail.com> wrote:
>
> This is not working with Merb version 0.5.2 as some of those methods
> are not longer there. (Merb::Server.merb_config) is one of them.
> L8er - Martin
>

> On Jan 3, 11:02pm, macournoyer <macourno...@gmail.com> wrote:
> > Hi Kevin,
> >
> > Sure, Merb already support Rack. But the sad thing is there's a lot of
> > hardcoded stuff in the merb script.
> > So to use it with thin you can create a config.ru file with this in
> > it:
> >
> > ======= config.ru =======
> > ENV['MERB_ENV'] = 'production'
> > require 'rubygems'
> > require 'rack'
> > require 'merb'
> > require 'thin'
> >
> > Merb::Server.instance_eval { @@merb_raw_opts = [] }
> > Merb::Server.merb_config
> > Merb::Server.initialize_merb
> >
> > run Merb::Rack::Adapter.new
> > =====================
> >
> > then run it with: rackup -s thin
> >

> > On Jan 3, 10:47pm, kevwil <kev...@gmail.com> wrote:
> >
> > > I'm really into Merb these days - can I use Thin with Merb?
> >
>

--
Cheers,

Kevin Williams
http://www.bantamtech.com/

macournoyer

unread,
Jan 17, 2008, 9:21:38 AM1/17/08
to thin-ruby
Like Kevin said, Thin support is gonna be builtin the next Merb
release (0.9). From the source, seems like you'll be able to launch it
like this:

merb.9 ... --adapter thin

Martin

unread,
Jan 17, 2008, 9:38:45 AM1/17/08
to thin-ruby
Thanks. I got the same answer from Ez on the merb IRC.
I will use 0.5.2 with EMongrel until Merb 0.9 is released.

Do not really matter since this is for dev environment.
A plus - Martin
Reply all
Reply to author
Forward
0 new messages