# How to include files in ruby webs?

**URL:** <https://www.ruby-forum.com/t/how-to-include-files-in-ruby-webs/67962>\
**Category:** Ruby\
**Created:** [September 8, 2006, 5:36am UTC](https://www.ruby-forum.com/t/how-to-include-files-in-ruby-webs/67962 "2006-09-08T05:36:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![edward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/90db22/32.png) [@edward](https://www.ruby-forum.com/u/edward)\
**Post date:** [September 8, 2006, 5:36am UTC](https://www.ruby-forum.com/t/how-to-include-files-in-ruby-webs/67962/1 "2006-09-08T05:36:49Z")

</div>

What is the equivalent of  
include(“library.php”);  
in ruby?

I googled this and “rendering shared partials in ruby” but can’t find  
anything.

Thanks,

Edward Tanguay  
All my projects: [http://www.tanguay.info](http://www.tanguay.info)

---

<div class="post-metadata">

**Author:** ![edward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/90db22/32.png) [@edward](https://www.ruby-forum.com/u/edward)\
**Post date:** [September 8, 2006, 5:44am UTC](https://www.ruby-forum.com/t/how-to-include-files-in-ruby-webs/67962/2 "2006-09-08T05:44:50Z")

</div>

On Sep 7, 2006, at 11:35 PM, Edward wrote:

> All my projects: [http://www.tanguay.info](http://www.tanguay.info)

Check out the docs for require and load.

---

<div class="post-metadata">

**Author:** ![edward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/90db22/32.png) [@edward](https://www.ruby-forum.com/u/edward)\
**Post date:** [September 8, 2006, 6:02am UTC](https://www.ruby-forum.com/t/how-to-include-files-in-ruby-webs/67962/3 "2006-09-08T06:02:51Z")

</div>

On Sep 7, 2006, at 8:35 PM, Edward wrote:

> What is the equivalent of  
> include(“library.php”);  
> in ruby?

Well, I don’t know php but ‘require’ is the equivalent of #include in  
C/C++ except that it automatically adds the guards against multiple  
inclusion. You can also leave off the .rb

Just use it like;  
require libfile

## HTH

For blocks are better cleft with wedges,  
Than tools of sharp or subtle edges,  
And dullest nonsense has been found  
By some to be the most profound.  
-Samuel Butler,

---

<div class="post-metadata">

**Author:** ![edward](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/90db22/32.png) [@edward](https://www.ruby-forum.com/u/edward)\
**Post date:** [September 8, 2006, 7:51am UTC](https://www.ruby-forum.com/t/how-to-include-files-in-ruby-webs/67962/4 "2006-09-08T07:51:03Z")

</div>

You can use require or load.

require ‘filename’  
loads filename.rb only once during the current executiion. This is what  
you would normally require. I dont know php all that well, but I think  
this is what you mean.

Edward wrote:

> All my projects: [http://www.tanguay.info](http://www.tanguay.info)

–  
Darshan P.

“The trouble with work is that it interferes with living.” - Peter  
Mckill 1968

[http://deepy.selfip.com](http://deepy.selfip.com)  
[http://www.singlehunt.com](http://www.singlehunt.com)  
[http://www.cribscout.com](http://www.cribscout.com)  
[http://www.ringtonelair.com](http://www.ringtonelair.com)
