Greetings, I am working on extending a new part of our site to use Ruby on Rails, and have several portions of the site that is included in external files. The rest of the site is built on top of MovableType and uses PHP Includes to reference the external files. Is there similar functionality in Ruby or Rails that I can use so I don''t have to update excess content in two different locations? Thanks. __________________________________________________ Justin Williams justin-2D/i1VWQ6ciB+jHODAdFcQ@public.gmane.org work: www.maczealots.com play: www.carpeaqua.com _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Check out render() E.g. render :partial => ''post'' # includes "_post.rhtml" Rob On Dec 15, 2005, at 10:29 PM, Justin Williams wrote:> Greetings, > > I am working on extending a new part of our site to use Ruby on > Rails, and have several portions of the site that is included in > external files. The rest of the site is built on top of > MovableType and uses PHP Includes to reference the external files. > > Is there similar functionality in Ruby or Rails that I can use so I > don''t have to update excess content in two different locations? > > Thanks. > > __________________________________________________ > Justin Williams justin-2D/i1VWQ6ciB+jHODAdFcQ@public.gmane.org > work: www.maczealots.com play: www.carpeaqua.com > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
yes. but will render() parse a file that is not built into the actual Rails application? For instance, in PHP I have this line in my <?php @include ("$document_root" . "movable-type/includes/ footer.php"); ?> I need to have an equivalent in Rails. From what the documentation says about render() its only for files that are within the actual rails application itself: these files I need to include are not. Thanks. __________________________________________________ Justin Williams justin-2D/i1VWQ6ciB+jHODAdFcQ@public.gmane.org work: www.maczealots.com play: www.carpeaqua.com On Dec 15, 2005, at 4:37 PM, Robert wrote:> Check out render() > > E.g. > > render :partial => ''post'' # includes "_post.rhtml" > > > > > Rob > > > On Dec 15, 2005, at 10:29 PM, Justin Williams wrote: > >> Greetings, >> >> I am working on extending a new part of our site to use Ruby on >> Rails, and have several portions of the site that is included in >> external files. The rest of the site is built on top of >> MovableType and uses PHP Includes to reference the external files. >> >> Is there similar functionality in Ruby or Rails that I can use so >> I don''t have to update excess content in two different locations? >> >> Thanks. >> >> __________________________________________________ >> Justin Williams justin-2D/i1VWQ6ciB+jHODAdFcQ@public.gmane.org >> work: www.maczealots.com play: www.carpeaqua.com >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Phillip Hutchings
2005-Dec-15 21:47 UTC
Re: PHP include() Type Functionality in Ruby/Rails
On 16/12/2005, at 10:42 AM, Justin Williams wrote:> For instance, in PHP I have this line in my > > <?php @include ("$document_root" . "movable-type/includes/ > footer.php"); ?> > > I need to have an equivalent in Rails. From what the > documentation says about render() its only for files that are > within the actual rails application itself: these files I need to > include are not.erb templates allow full Ruby code. <%= File.open(''/path/to/my/file'') do |file| file.read end %> -- Phillip Hutchings phillip.hutchings-QrR4M9swfipWk0Htik3J/w@public.gmane.org
On 12/15/05, Justin Williams <justin-2D/i1VWQ6ciB+jHODAdFcQ@public.gmane.org> wrote:> I need to have an equivalent in Rails. From what the documentation > says about render() its only for files that are within the actual > rails application itself: these files I need to include are not.Where are your files located? Ruby has a "require" function that works somewhat like you are saying. For instance, if you have the PDF::Writer library installed, and you want to use it in a controller, you just put: require ''pdf/writer'' at the beginning of the file. Works like a charm!
Ezra Zygmuntowicz
2005-Dec-15 22:20 UTC
Re: PHP include() Type Functionality in Ruby/Rails
On Dec 15, 2005, at 1:42 PM, Justin Williams wrote:> yes. but will render() parse a file that is not built into the > actual Rails application? > > For instance, in PHP I have this line in my > > <?php @include ("$document_root" . "movable-type/includes/ > footer.php"); ?><%= render :file => "/home/users/foobar/template.rhtml %> With that you will be able to render an rhtml template that is anywhere on the computer. Cheers- -Ezra> > I need to have an equivalent in Rails. From what the > documentation says about render() its only for files that are > within the actual rails application itself: these files I need to > include are not. > > Thanks. > > __________________________________________________ > Justin Williams justin-2D/i1VWQ6ciB+jHODAdFcQ@public.gmane.org > work: www.maczealots.com play: www.carpeaqua.com > > On Dec 15, 2005, at 4:37 PM, Robert wrote: > >> Check out render() >> >> E.g. >> >> render :partial => ''post'' # includes "_post.rhtml" >> >> >> >> >> Rob >> >> >> On Dec 15, 2005, at 10:29 PM, Justin Williams wrote: >> >>> Greetings, >>> >>> I am working on extending a new part of our site to use Ruby on >>> Rails, and have several portions of the site that is included in >>> external files. The rest of the site is built on top of >>> MovableType and uses PHP Includes to reference the external files. >>> >>> Is there similar functionality in Ruby or Rails that I can use so >>> I don''t have to update excess content in two different locations? >>> >>> Thanks. >>> >>> __________________________________________________ >>> Justin Williams justin-2D/i1VWQ6ciB+jHODAdFcQ@public.gmane.org >>> work: www.maczealots.com play: www.carpeaqua.com >>> >>> _______________________________________________ >>> Rails mailing list >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-Ezra Zygmuntowicz Yakima Herald-Republic WebMaster http://yakimaherald.com 509-577-7732 ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org
Phillip Hutchings wrote:> <%= File.open(''/path/to/my/file'') do |file| > file.read > end > %>Or just File.read(''path''). -- Posted via http://www.ruby-forum.com/.
Phillip Hutchings
2005-Dec-15 22:40 UTC
Re: Re: PHP include() Type Functionality in Ruby/Rails
On 16/12/2005, at 11:35 AM, Andreas S. wrote:> Or just File.read(''path'').Um. Yes. Duh. I''ve been coding in PHP all morning, gotta keep a roof over my head and everything. It''s just so mind numbing ;) -- Phillip Hutchings phillip.hutchings-QrR4M9swfipWk0Htik3J/w@public.gmane.org