# Dynamic content in Extension (Forms in Radiant)

**URL:** <https://www.ruby-forum.com/t/dynamic-content-in-extension-forms-in-radiant/118312>\
**Category:** Radiant CMS\
**Created:** [October 25, 2007, 4:12pm UTC](https://www.ruby-forum.com/t/dynamic-content-in-extension-forms-in-radiant/118312 "2007-10-25T16:12:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bouldr-matt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/85e7bf/32.png) [@bouldr-matt](https://www.ruby-forum.com/u/bouldr-matt)\
**Post date:** [October 25, 2007, 4:12pm UTC](https://www.ruby-forum.com/t/dynamic-content-in-extension-forms-in-radiant/118312/1 "2007-10-25T16:12:18Z")

</div>

I currently have two Rails apps for my site: one Radiant that serves  
the static context and a regular Rails app that does forms and  
authentication. Apache sits in front and figures out which app gets  
which URL.

It’s becoming a problem – as you can imagine – since both apps need  
to look the same. What I’d really like to do is merge the dynamic  
functionality into an extension and use Radiant to wrap the dynamic  
content with the specified layout.

I’ve read the tutorial on creating extensions and have already created  
a custom tag or two. But I can’t figure out how to use my layout when  
rendering from my extension:

* * *

…/extensions/user\_status/user\_status\_extension.rb

# Define a new custom route

class UserStatusExtension \< Radiant::Extension  
…

define\_routes do |map|  
map.with\_options(:controller =\> ‘foo’) do |foo|  
foo.bar ‘foo/bar’, :action =\> ‘bar’  
end  
end

…  
end

* * *

…/extensions/user\_status/app/controllers/foo\_controller.rb

# Have empty action that should point right to view

def bar  
end

* * *

…/extensions/user\_status/app/views/foo/bar.rhtml

Hello from Bar!

Now when I hit my Radiant app with: [http://localhost:3000/foo/bar](http://localhost:3000/foo/bar)  
“Hello from Bar!” is rendered, but it is rendered using the Radiant  
admin layout (in radiant/app/views/layouts/application.rhtml.  
However, I want to be able to specify (either in my controller or my  
view) to use the custom layout that is being pulled from the Radiant  
database. For example, can I do this in my controller:

layout(:from\_db)

Does this make sense? Is anyone else mixing apps like this? Is  
anyone doing forms in Radiant and how are you going about it?

Thanks a lot. I hope to add to the site’s documentation once I get my  
thoughts together and get through this project.

---

<div class="post-metadata">

**Author:** ![bouldr-matt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/85e7bf/32.png) [@bouldr-matt](https://www.ruby-forum.com/u/bouldr-matt)\
**Post date:** [October 25, 2007, 4:23pm UTC](https://www.ruby-forum.com/t/dynamic-content-in-extension-forms-in-radiant/118312/2 "2007-10-25T16:23:24Z")

</div>

Matt,

Check out the “share\_layouts” extension in the core repository. It lets  
you specify a Radiant layout to use when rendering your standard Rails  
actions.

Sean

---

<div class="post-metadata">

**Author:** ![bouldr-matt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/85e7bf/32.png) [@bouldr-matt](https://www.ruby-forum.com/u/bouldr-matt)\
**Post date:** [October 25, 2007, 4:56pm UTC](https://www.ruby-forum.com/t/dynamic-content-in-extension-forms-in-radiant/118312/3 "2007-10-25T16:56:44Z")

</div>

Wow that is exactly what I was looking for 🙂

I tried creating a new radiant app, froze to edge, and added the  
extension. When I start up, I get this error:

mhughes@mhughes:~/work/iona/foo$ script/server  
=\> Booting Mongrel (use ‘script/server webrick’ to force WEBrick)  
=\> Rails application starting on [http://0.0.0.0:3000](http://0.0.0.0:3000)  
=\> Call with -d to detach  
=\> Ctrl-C to shutdown server  
\*\* Starting Mongrel listening at 0.0.0.0:3000  
\*\* Starting Rails with development environment…  
Exiting  
./script/…/config/…/vendor/radiant/vendor/rails/activesupport/lib/active\_support/dependencies.rb:477:in  
`const_missing': uninitialized constant ShareLayoutsExtension::ApplicationController (NameError) from /home/mhughes/work/iona/foo/vendor/extensions/share_layouts/share_layouts_extension.rb:11:in `activate’  
from  
./script/…/config/…/vendor/radiant/lib/radiant/extension.rb:39:in  
`activate' from ./script/../config/../vendor/radiant/lib/radiant/extension_loader.rb:118:in `activate’  
from  
./script/…/config/…/vendor/radiant/lib/radiant/extension\_loader.rb:106:in  
`activate_extensions' from ./script/../config/../vendor/radiant/lib/radiant/extension_loader.rb:97:in `select’  
from  
./script/…/config/…/vendor/radiant/lib/radiant/extension\_loader.rb:97:in  
`activate_extensions' from ./script/../config/../vendor/radiant/lib/radiant/extension_loader.rb:42:in `run’  
from  
./script/…/config/…/vendor/radiant/lib/radiant/initializer.rb:45:in  
`initialize_extensions' ... 31 levels... from ./script/../config/../vendor/radiant/vendor/rails/activesupport/lib/active_support/dependencies.rb:495:in `require’  
from  
./script/…/config/…/vendor/radiant/vendor/rails/railties/lib/commands/server.rb:39  
from script/server:3:in `require’  
from script/server:3

Any ideas?
