I was wondering if anyone had an opinion on how to do file includes in RoR. I am currently doing it with JavaScript. I am building a CMS for a dynamic website. I want a tool that lets non-programmers build a website by filling out some forms, making some choices (templates, images, etc..), and previewing the page before publishing it. The tool should take the info from the CMS forms and populate modules (mini web pages) that will then make-up the website. I plan on building the final webpage by including the modules in the template. So anyways, what''s the Ruby way to do includes? Code and pointers to tutorials are always helpful. Thanks in Advance -- K --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
The very same thing that bothers me in ruby. We can do this "include" very easily in PHP. And I can''t seem to find the same method to "include" in ruby. As for rails, maybe you can try using render_component, like me. I use render_component to include modules (as in joomla) in pages. Or using helpers to generate components and modules (as in joomla). I admit that this seem kind of messy... But I can''t think of any other way right now... ~_~ On 11/28/06, Kim <Kim.Griggs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > I was wondering if anyone had an opinion on how to do file includes in > RoR. I am currently doing it with JavaScript. > > I am building a CMS for a dynamic website. I want a tool that lets > non-programmers build a website by filling out some forms, making some > choices (templates, images, etc..), and previewing the page before > publishing it. > > The tool should take the info from the CMS forms and populate modules > (mini web pages) that will then make-up the website. I plan on building > the final webpage by including the modules in the template. > > So anyways, what''s the Ruby way to do includes? > > Code and pointers to tutorials are always helpful. > > Thanks in Advance -- K > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
render :partial => "path/to/partial" Remember, partials can take in variables as well, or can simply act like includes and use variables declared in the request scope (@ variables) On 11/27/06, Prayana Galih <prayana.galih-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > The very same thing that bothers me in ruby. We can do this "include" very > easily in PHP. And I can''t seem to find the same method to "include" in > ruby. > > As for rails, maybe you can try using render_component, like me. I use > render_component to include modules (as in joomla) in pages. Or using > helpers to generate components and modules (as in joomla). > > I admit that this seem kind of messy... But I can''t think of any other way > right now... ~_~ > > On 11/28/06, Kim < Kim.Griggs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > I was wondering if anyone had an opinion on how to do file includes in > > RoR. I am currently doing it with JavaScript. > > > > I am building a CMS for a dynamic website. I want a tool that lets > > non-programmers build a website by filling out some forms, making some > > choices (templates, images, etc..), and previewing the page before > > publishing it. > > > > The tool should take the info from the CMS forms and populate modules > > (mini web pages) that will then make-up the website. I plan on building > > the final webpage by including the modules in the template. > > > > So anyways, what''s the Ruby way to do includes? > > > > Code and pointers to tutorials are always helpful. > > > > Thanks in Advance -- K > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ljredpath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Nov-28 11:59 UTC
Re: Includes: The Ruby Way?
>> The very same thing that bothers me in ruby. We can do this "include" very >> easily in PHP. And I can''t seem to find the same method to "include" in >> ruby.Bear in mind that PHP''s include functionality has two purposes - 1) including other source code - the Ruby equivalent of this is require. 2) Including templates within templates (like server-side includes) - the reason PHP makes this easy is because it was originally designed as a templating language. Ruby wasn''t therefore the whole concept of SSIs in Ruby wouldn''t make sense. In Rails, this is what partials are for. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks everyone. Partials work great. --K --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I need to include an outside resource. Is it possible to do with render or is there something else that will work? <%= render :partial => "http://domain.com:6969/files/" %> Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Fri, Dec 14, 2007 at 04:03:22PM +0100, Peter Heywood wrote:> I need to include an outside resource. Is it possible to do with render > or is there something else that will work? > > <%= render :partial => "http://domain.com:6969/files/" %>There are two plausible ways to go about this: You''ll need to require ''open-uri'' for this first one, which has the Rails app connect to and read from the URL: <%= open("http://domain.com:6969/files/", &:read) %> The other way is to use an HTML iframe (and you''ll need to check the syntax on that). This makes the client browser request the URL on its own: <iframe src="http://domain.com:6969/files/" />> Thanks--Greg --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Gregory Seidman wrote:> On Fri, Dec 14, 2007 at 04:03:22PM +0100, Peter Heywood wrote: >> I need to include an outside resource. Is it possible to do with render >> or is there something else that will work? >> >> <%= render :partial => "http://domain.com:6969/files/" %> > > There are two plausible ways to go about this: > > You''ll need to require ''open-uri'' for this first one, which has the > Rails > app connect to and read from the URL: > > <%= open("http://domain.com:6969/files/", &:read) %> > > The other way is to use an HTML iframe (and you''ll need to check the > syntax > on that). This makes the client browser request the URL on its own: > > <iframe src="http://domain.com:6969/files/" /> > >> Thanks > --GregMany thanks Greg I was using the iframe as a stop gap but IE does not display it properly. Your first suggestion works great!! Thanks again, Peter -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---