# Using Rails app within radiant

**URL:** <https://www.ruby-forum.com/t/using-rails-app-within-radiant/115701>\
**Category:** Radiant CMS\
**Created:** [September 27, 2007, 7:59pm UTC](https://www.ruby-forum.com/t/using-rails-app-within-radiant/115701 "2007-09-27T19:59:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jorge\_santiago](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@jorge\_santiago](https://www.ruby-forum.com/u/jorge_santiago)\
**Post date:** [September 27, 2007, 7:59pm UTC](https://www.ruby-forum.com/t/using-rails-app-within-radiant/115701/1 "2007-09-27T19:59:57Z")

</div>

Hi,

I have radiant running my website and would like to use some models  
and functions from another rails app running in the same server. Any  
ideas on how to do this if its possible?

Thanks in advance,

jorge.

---

<div class="post-metadata">

**Author:** ![jorge\_santiago](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@jorge\_santiago](https://www.ruby-forum.com/u/jorge_santiago)\
**Post date:** [September 27, 2007, 8:35pm UTC](https://www.ruby-forum.com/t/using-rails-app-within-radiant/115701/2 "2007-09-27T20:35:51Z")

</div>

Jorge,

If your app is ActiveResource-compatible, that might be an easy way to  
integrate them.

Sean

---

<div class="post-metadata">

**Author:** ![jorge\_santiago](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@jorge\_santiago](https://www.ruby-forum.com/u/jorge_santiago)\
**Post date:** [September 27, 2007, 10:14pm UTC](https://www.ruby-forum.com/t/using-rails-app-within-radiant/115701/3 "2007-09-27T22:14:08Z")

</div>

Well, my rails app it’s a bit old, so it’s not  
ActiveResource-compatible. It would be great though, to rewrite it and  
make it RESTful in the future, but currently I don’t have the time. Is  
there another way to achieve what I’m looking for?

Thanks,

Jorge.

---

<div class="post-metadata">

**Author:** ![jorge\_santiago](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@jorge\_santiago](https://www.ruby-forum.com/u/jorge_santiago)\
**Post date:** [September 27, 2007, 11:54pm UTC](https://www.ruby-forum.com/t/using-rails-app-within-radiant/115701/4 "2007-09-27T23:54:12Z")

</div>

You could import some of your models into a Radiant extension and then  
use them there. They may have to connect to your other database  
manually, i.e. inside their declaration.

Sean

---

<div class="post-metadata">

**Author:** ![jorge\_santiago](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@jorge\_santiago](https://www.ruby-forum.com/u/jorge_santiago)\
**Post date:** [October 1, 2007, 10:53pm UTC](https://www.ruby-forum.com/t/using-rails-app-within-radiant/115701/5 "2007-10-01T22:53:48Z")

</div>

Hi Sean,

I’ve explored further this approach and it looks exactly what I’m  
looking for, but I’m having problems loading the AR models into  
Radiant.

I created the extension and the custom tags, (pretty easy and slick  
indeed :), and put the require environment.rb of my rails app at the  
top of the  
‘radiantsite/vendor/extensions/myextension/lib/myextension.rb’  
file but I got this errors:

warning: already initialized constant OPTIONS  
/opt/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/mongrel.rb:18:  
undefined method `options’ for []:Array (NoMethodError)

and the radiant’s mongrel server doesn’t boot anymore.

Do I need to require the environment.rb file somewhere else or is  
there other method to load my app’s models into the radiant.

Thanks in advance!

jorge.

---

<div class="post-metadata">

**Author:** ![jorge\_santiago](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@jorge\_santiago](https://www.ruby-forum.com/u/jorge_santiago)\
**Post date:** [October 2, 2007, 4:11pm UTC](https://www.ruby-forum.com/t/using-rails-app-within-radiant/115701/6 "2007-10-02T16:11:01Z")

</div>

I’ve copied my rails app environment.rb customizations to the radiant  
project’s environment.rb and it’s now it’s loading ok, but still my  
models are not yet accesible from radiant. I’m using  
ActiveRecord::Base.establish\_conection in the extension’s activate  
method to connect to the rails db, but I don’t know how to load my  
rails model definitions. Could you please give me some details on how  
to do it? Sorry if it’s something obvius but I’m really lost here.

Thanks a lot for your help,

Jorge

---

<div class="post-metadata">

**Author:** ![jorge\_santiago](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@jorge\_santiago](https://www.ruby-forum.com/u/jorge_santiago)\
**Post date:** [October 1, 2007, 11:05pm UTC](https://www.ruby-forum.com/t/using-rails-app-within-radiant/115701/7 "2007-10-01T23:05:00Z")

</div>

Jorge,

You shouldn’t require the environment.rb of your Rails app directly.  
Copy any customizations you have made either into your Radiant  
project’s environment.rb or into the activate method of your  
extension. Hopefully that should fix the issue.

Sean

---

<div class="post-metadata">

**Author:** ![jorge\_santiago](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@jorge\_santiago](https://www.ruby-forum.com/u/jorge_santiago)\
**Post date:** [October 2, 2007, 4:16pm UTC](https://www.ruby-forum.com/t/using-rails-app-within-radiant/115701/8 "2007-10-02T16:16:18Z")

</div>

As long as they are in app/models or lib/ of your extension, they  
should be accessible; that is, they will be in the load path. How you  
integrate them into the Radiant application is another story… you  
may need to create some controllers and views, or maybe some Radius  
tags. Both of those are briefly covered in the extension tutorial on  
the wiki.

Sean
