SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: Questions about using RoR
-
May 5, 2006, 19:46 #1
- Join Date
- Nov 2001
- Posts
- 1,194
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Questions about using RoR
I've been using PHP with all of my sites the past 3 years and am about 1/4 of the way through Agile Web Development with Rails. I have a couple of questions and would appreciate it if someone could answer them.
Should I just use RoR on websites that require database connections on just about every page? I'm confused about when to use PHP or RoR or would it be best to just use RoR all the time?
How about in this example? Say I have a site that has 15 pages, only one of which that displays info from a database for a calendar. Would it be better to use PHP or RoR in this situation?
In PHP I use includes a lot for templates for my header, footer, sidebar, etc. Can someone give me an example of how to do this in RoR? Is this what most sites running RoR do or do they just have the header/footer on multiple pages? I like using includes because then I can just update one page when I need to make a global change.
If someone who knows HTML were to ask what RoR is, what would be a good way to explain it in laymans terms (instead of just saying it's a web-based framework that uses the ruby scripting language)?John Saunders
-
May 5, 2006, 21:24 #2
- Join Date
- Jun 2004
- Location
- California
- Posts
- 440
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by JohnSaunders
Originally Posted by JohnSaunders
Originally Posted by JohnSaunders
Code:<%= yield %>
The layout which is used is set from the controller.
Originally Posted by JohnSaunders
-
May 6, 2006, 11:46 #3
- Join Date
- Aug 2005
- Posts
- 986
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
So a typical layout looks like:
Code:<html> <head> <%= stylesheet_link_tag 'style' %> <!-- You can use inline Ruby here. This creates a <link ... /> tag --> </head> <body> <h1>My Site</h1> <%= yield %> <!-- yield will be replaced by a page specific template --> </body> </html>
-
May 9, 2006, 17:08 #4
- Join Date
- Nov 2001
- Posts
- 1,194
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks for the answers.
So for a site that would have several pages of content that would be fetched from a database would it be best to set up the backend/CMS using RoR then just use PHP to fetch the info from the databases that would display the info (such as a list of members, calendar, etc.)?John Saunders
-
May 10, 2006, 08:08 #5
- Join Date
- Aug 2005
- Posts
- 986
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
No, I would do everything in RoR, that's easier. If already use RoR for the backend, it will be easier to use it for the frontend too. (otherwise you'll be re-doing things in PHP, like database handling (model)). You can put static HTML pages in the public folder.
-
May 12, 2006, 12:51 #6
- Join Date
- Apr 2005
- Posts
- 485
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by JohnSaunders
if you want to learn RoR and don't mind spending more time, RoR is the no brainer.
if you know you will want to run RoR apss on the same server down the road, you reduce complexity by coding the simple app in RoR so you don't have to admin for PHP and Ruby.
ruby is comparable to php inthat they are both scripting languages. however, the syntax is different and the structure is different.
Rails is a system to organize your ruby code AND some ruby code to perform certain functions. for example, adodb is my php db abstration layer. activerecord performs this function (and more!) in rails. rails also has code that will extract information from your db and display it if you follow certain conventions. this is done automagically. that's what rails can do for you.
RoR is nothing magical, rather, it is a well thought out language applied in a well thought out way. its focus was on OO programming, not procedural programming.
i'm just learning it, too. just when i'm comfortable with php... i need to learn something new. having said that, applying the principles in the agile web dev with rails book, you will can easily improve your php coding style. i know i did.
Bookmarks