Skip to content

Instantly share code, notes, and snippets.

@glaville
Created August 26, 2010 07:18
Show Gist options
  • Save glaville/550986 to your computer and use it in GitHub Desktop.
Save glaville/550986 to your computer and use it in GitHub Desktop.
With the last fixes, scaffold_extensions work for this example, but override layout of the other Ramaze::Controller in the same Ramaze::App
- /foo should use /layout/foo.xhtml as layout, and be renderer an a gray background
- /f/forum should use /layout/foo.xhtml as well
The problem seems to be linked to the fact the Ramaze adapter now updates the *existing containing Ramaze::App* with its own path (here, default one and :forum) and affect as such any other controller in theses Apps.
# File: layout/foo.xhtml
<div style="background-color: gray">
#@content
</div>
# Files: view/f/forum/index.xhtml
# view/foo/index.xhtml
<p>
#{@greeting}
</p>
#!/usr/bin/env ruby
# encoding: UTF-8
require 'ramaze'
require 'sequel'
$LOAD_PATH = $LOAD_PATH.unshift("./lib")
require 'scaffolding_extensions'
# Model stuff
DB = Sequel.sqlite
DB.create_table :entries do
primary_key :id
String :value
end
class Entry < Sequel::Model(:entries)
end
# First, we try without explicit App
class FooController < Ramaze::Controller
layout 'foo'
def index
@greeting = "hello world!"
end
end
class AdminController < Ramaze::Controller
map '/admin_se'
scaffold_all_models :only => [ Entry ]
end
# Next, try with an app named 'forum'
class ForumController < Ramaze::Controller
map '/forum', :forum
layout 'foo'
def index
@greeting = "hello, forum!"
end
end
class EntryController < Ramaze::Controller
map '/entry_se', :forum
scaffold_all_models :only => [ Entry ]
end
forum = Ramaze::App[:forum]
forum.location = '/f'
Ramaze.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment