I'm trying to get a Merb very_flat app to work in the root of a Rails
app.  It's been a pain and required overriding an internal method, but
I've finally got it somewhat working.  I think the problem is that
Merb is overriding the configuration given to Merb::Config inside
Merb.start.

Here's the code I'm using:

require 'rubygems'
require 'merb-core'

use_template_engine :erb

Merb::Config.use { |c|
  c[:session_store]       = 'cookie'
  c[:exception_details]   = true
  c[:log_level]           = :debug
  c[:log_stream]          = $stdout
  c[:reload_classes]   = false
  c[:reload_templates] = false
  c[:use_mutex] = false
  c[:fork_for_class_load] = false
}

Merb::Router.prepare do
  match('/').to(:controller => 'merb_setup', :action =>'index')
end

class MerbSetup < Merb::Controller
  def index
    "Hi, I am 'very flat' Merb application. I have everything in one
single file and well suited for dynamic stub pages."
  end
end

# Needed to override this or Merb would give an error: http://p.ramaze.net/13770
def Merb.load_paths
  Hash.new{|h,k| ["", nil]}
end

Merb.disable(:initfile)
p Merb::Config.instance_variable_get(:@configuration)
begin
  Merb.start(%w'-a mongrel')
rescue SystemExit => e
  p Merb::Config.instance_variable_get(:@configuration)
  e.backtrace.each{|x| puts x}
end


Here's the output I get:

$ ruby merb_setup.rb
{:log_stream=>#<IO:
0x20cc11368>, :adapter=>"runner", :reap_workers_quickly=>true, 
:reload_classes=>false, :log_auto_flush=>false, :session_store=>"cookie", 
:bind_fail_fatal=>true, :reload_templates=>false, :name=>"merb", 
:exception_details=>true, :environment=>"development", :merb_root=>"/
data/code/scaffolding_extensions/
test_site", :use_mutex=>false, :log_level=>:debug, :disabled_components=>
[:initfile], :deferred_actions=>
[], :host=>"0.0.0.0", :fork_for_class_load=>false, :verbose=>false, 
:port=>"4000", :log_delimiter=>"
~ "}
 ~ Parent pid: 2790
merb : worker (port 4000) ~ Starting Mongrel at port 4000
merb : worker (port 4000) ~ Successfully bound to port 4000
^C ~ Reaping Workers
{:log_stream=>#<IO:
0x20cc11368>, :adapter=>"mongrel", :reap_workers_quickly=>true, 
:reload_classes=>true, :log_auto_flush=>false, :bind_fail_fatal=>true, 
:name=>"merb", :environment=>"development", :merb_root=>"/
data/code/scaffolding_extensions/
test_site", :use_mutex=>true, :log_level=>:info, :disabled_components=>
[:initfile], :deferred_actions=>
[], :host=>"0.0.0.0", :fork_for_class_load=>true, :verbose=>false, 
:port=>"4000", :log_delimiter=>"
~ "}
/usr/local/lib/ruby/gems/1.8/gems/merb-core-1.0.3/lib/merb-core/
bootloader.rb:667:in `exit'
/usr/local/lib/ruby/gems/1.8/gems/merb-core-1.0.3/lib/merb-core/
bootloader.rb:667:in `exit_gracefully'
/usr/local/lib/ruby/gems/1.8/gems/merb-core-1.0.3/lib/merb-core/
bootloader.rb:715:in `start_transaction'
/usr/local/lib/ruby/gems/1.8/gems/merb-core-1.0.3/lib/merb-core/
bootloader.rb:739:in `call'
/usr/local/lib/ruby/gems/1.8/gems/merb-core-1.0.3/lib/merb-core/
bootloader.rb:739:in `select'
/usr/local/lib/ruby/gems/1.8/gems/merb-core-1.0.3/lib/merb-core/
bootloader.rb:739:in `start_transaction'
/usr/local/lib/ruby/gems/1.8/gems/merb-core-1.0.3/lib/merb-core/
bootloader.rb:725:in `loop'
/usr/local/lib/ruby/gems/1.8/gems/merb-core-1.0.3/lib/merb-core/
bootloader.rb:725:in `start_transaction'
/usr/local/lib/ruby/gems/1.8/gems/merb-core-1.0.3/lib/merb-core/
bootloader.rb:691:in `loop'
/usr/local/lib/ruby/gems/1.8/gems/merb-core-1.0.3/lib/merb-core/
bootloader.rb:691:in `start_transaction'
/usr/local/lib/ruby/gems/1.8/gems/merb-core-1.0.3/lib/merb-core/
bootloader.rb:623:in `run'
/usr/local/lib/ruby/gems/1.8/gems/merb-core-1.0.3/lib/merb-core/
bootloader.rb:99:in `run'
/usr/local/lib/ruby/gems/1.8/gems/merb-core-1.0.3/lib/merb-core/
server.rb:172:in `bootup'
/usr/local/lib/ruby/gems/1.8/gems/merb-core-1.0.3/lib/merb-core/
server.rb:42:in `start'
/usr/local/lib/ruby/gems/1.8/gems/merb-core-1.0.3/lib/merb-core.rb:
170:in `start'
merb_setup.rb:35


As you can see from the output, the configuration I give is overridden
(e.g. :reload_classes).  I tried modifying the configuration outside
of the block and before Merb.start based on a suggestion from wycats
in #merb, but that didn't change anything (which makes sense since you
can see it is correct in the first dump).

Am I doing something wrong?  Is this the expected behavior?  Is there
anything I can do to fix this?

Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to