SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Evangelist
    Join Date
    Apr 2005
    Posts
    485
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ruby/Rails and PHP? Is It Possible

    hi all.

    i really like some aspects of RoR and i will be learning and applying it over the next few months.

    having said that, i'm a little scared because i'm comfortable using a php forms class to generate linked select boxes (select box 2 changes as select box 1 is updated).

    i'm under the impression this is doable in rails, but it isn't trivial - meaning i'll be burning a lot of time getting something usable. burning time doesn't seem like apleasant experience at this juncture - especially when i have it down pat on PHP.

    can i mix these technologies on a limited basis or am i just out of luck?

    tia...

    can php be used in conjunction with rails?

  2. #2
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use either/or on the same server. You couldn't jump into PHP in the middle of a Rails template if that's what you are asking. But you could have php pages available in your public directory.

    Honestly though, doing linked select boxes in Rails with AJAX is pretty easy.

    Someone else was asking about this recently:
    http://www.sitepoint.com/forums/showthread.php?t=326963
    ezmobius1 suggested this link:
    http://www.roryhansen.ca/?p=9
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  3. #3
    SitePoint Evangelist
    Join Date
    Apr 2005
    Posts
    485
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by samsm
    You can use either/or on the same server. You couldn't jump into PHP in the middle of a Rails template if that's what you are asking. But you could have php pages available in your public directory.

    Honestly though, doing linked select boxes in Rails with AJAX is pretty easy.

    Someone else was asking about this recently:
    http://www.sitepoint.com/forums/showthread.php?t=326963
    ezmobius1 suggested this link:
    http://www.roryhansen.ca/?p=9
    yah, that was me! -lol-

    it didn't look easy to me, but i probably haven't just jumped into the "deep end," yet.

    time to jump? i think so!

  4. #4
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's an example I did some time ago:

    Code:
      <% for city in @cities %>
        <option value="<%= city.id %>"><%= city.name %>, <%= city.state.name %></option>
      <% end %>
    </select>
    <%= observe_field('exact_city', :frequency => 0.25, :update => 'new_checkboxes', :url => { :action => :exact_city }, :with => "'city='+value" ) %>
    <div id="new_checkboxes"></div>
    Instead of states, I was looking at a list of cities and trying to get the exact city. Does that shed any light?

    (and stick to one thread next time!)
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  5. #5
    SitePoint Zealot Packetloss's Avatar
    Join Date
    Aug 2003
    Location
    Behind You
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's cool you can use both. I was thinking of developing a frontend of site with PHP but develop the backend using Ruby (gotta love scaffold!). Would that run into any problems?
    My links: [ Blog ] - [ deviantArt ]

  6. #6
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Packetloss
    It's cool you can use both. I was thinking of developing a frontend of site with PHP but develop the backend using Ruby (gotta love scaffold!). Would that run into any problems?
    Can you have two separate applications working on the same database? Sure.

    However, in a situation where you are building something from scratch, I'd wonder what the purpose was. If you are making a backend with Rails, then you are probably setting up relationships in the models which could also be used for the frontend. It seems to me like by doing something in two languages, you might be doing some of the same work twice. You could easily argue that that is a problem.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  7. #7
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Packetloss
    I was thinking of developing a frontend of site with PHP
    You can use ERB templates much like PHP, just replace <?php echo $XXX ?> with <%= @XXX %>. That's the default templating engine in Rails.

    Douglas
    Hello World

  8. #8
    SitePoint Guru OfficeOfTheLaw's Avatar
    Join Date
    Apr 2004
    Location
    Quincy
    Posts
    636
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Packetloss
    It's cool you can use both. I was thinking of developing a frontend of site with PHP but develop the backend using Ruby (gotta love scaffold!). Would that run into any problems?
    You mean use php for templating!?

    That's what it was originally designed for, after all.

    James Carr, Software Engineer


    assertEquals(newXPJob, you.ask(officeOfTheLaw));

  9. #9
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want good templates along the lines of Smarty check out LiquidLiquid

  10. #10
    SitePoint Evangelist lirux's Avatar
    Join Date
    Jan 2001
    Location
    Lisboa : Portugal
    Posts
    418
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Packetloss
    It's cool you can use both. I was thinking of developing a frontend of site with PHP but develop the backend using Ruby (gotta love scaffold!). Would that run into any problems?
    If you mean running the site on php, and then having something like admin.example.com using rails, it should be ok. You just create the site with php, then your admin section as a rails app, and they both interact with the same database.

    I must tell you rhtml is very easy.. I don't know what level of complexity this site will have, but a setup like this probablly wont be worth the extra effort, compared with just runnng everything on rails!
    Duarte Carrilho da Graša
    RailsHelp.com: Searchable Rails reference
    CACA: Committee for the Annihilation of Complicated Acronyms


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •