SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist Jhorra's Avatar
    Join Date
    Sep 2004
    Location
    Phoenix, Az
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Two non-related questions

    My first question is on hosting. We have a dedicated server running a few PHP aps. I am this close to building the next app in Ruby, and converting everything else over. My questions is, how hard is it going to be to host a PHP and Rails app side by side? Will it slow down the Rails app due to constraints from the PHP apps?

    My second question is this, I found a nl2br equivelent online, and am trying to use it. I put the function into my helper file, but it doesn't seem to do anything when I call it. I have it in the application helper file, thinking this would allow me to call it from anywhere in the app. It's a very simple function, shown here:
    Code:
      def nl2br(s)
        s.gsub(/n/, '<br>')
      end

    Here is where I call it on my page.
    nl2br(@blog.body)

    I get no errors, but it doesn't seem to do anything either. Can anyone help?

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Jhorra View Post
    My first question is on hosting. We have a dedicated server running a few PHP aps. I am this close to building the next app in Ruby, and converting everything else over. My questions is, how hard is it going to be to host a PHP and Rails app side by side? Will it slow down the Rails app due to constraints from the PHP apps?
    Pretty easy to host the two on the same server. Unless your PHP apps are already straining the server you should be fine. And if the PHP apps are straining the server I'd recommend you get a second one anyway.
    Quote Originally Posted by Jhorra
    My second question is this, I found a nl2br equivelent online, and am trying to use it. I put the function into my helper file, but it doesn't seem to do anything when I call it. I have it in the application helper file, thinking this would allow me to call it from anywhere in the app. It's a very simple function, shown here:
    Code:
      def nl2br(s)
        s.gsub(/n/, '<br>')
      end

    Here is where I call it on my page.
    nl2br(@blog.body)

    I get no errors, but it doesn't seem to do anything either. Can anyone help?
    Don't write your own. Use simple_format() which converts single linebreaks to br tags and double linebreaks to paragraphs.

    Or use Textile/Markdown/BBCode, which will let you do a lot more than linebreaks if you want.

  3. #3
    SitePoint Evangelist Jhorra's Avatar
    Join Date
    Sep 2004
    Location
    Phoenix, Az
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there any special setup required, I'm not entirely sure how to make them run side by side.

  4. #4
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The nl2br code was written by an inexperienced Ruby programming coming from PHP ;-). (1) it uses a regex to replace a fixed string...(2) the code doesn't work: it replaces "n" and not newlines.

    Code:
    def nl2br(s)
      s.gsub "\n", "<br />"
    end
    But anyway, use simple_markup, sanitize.


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
  •