Posts Tagged ‘rails’

Peaceful coexistence between Rails and PHP

Tuesday, March 3rd, 2009

Have a Rails application you’d like to have coexist with some existing PHP code? Our website is set up as a Rails app, and we’d like to add bbpress, a php forum application, deployed as a directory. Generally speaking, it works fine – but the DirectoryIndex, in this case index.php, doesn’t get picked up and you are returned the 404 page from your Rails application.

To be sure, make sure you have the DirectoryIndex set up with index.php on the end. DirectoryIndex index.html index.php

now set up mod_rewrite to take care of business
RewriteEngine on

RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f 
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME}/index.php -f 
RewriteRule ^(.*)$ $1/index.php [QSA,L] 

If you’re using Mongrel, make sure you have those rewrite rules in the Apache config file before it the request gets rewritten off to the proxy balancer.

That’s all she wrote.

Redmine/Rails email through Gmail SMTP

Thursday, December 4th, 2008

Here is a bit of help getting Redmine, or any Rails app, to send email over SMTP through an existing Gmail account. It’s quite easy to set up and you gain the usual perks of having everything centralized in a Gmail account. Note: this works with Google Apps for your domain, too.

First you’ll need to install the smtp_tls plugin into your application’s lib directory so you can correctly authenticate. For posterity, I’ve uploaded a copy smtp_tls.rb along with this post.

www@host:~/redmine$ cd lib
www@host:~/redmine/lib$ curl -O http://blog.expandrive.com/wp-content/uploads/2008/12/smtp_tls.rb

Redmine utilizes email.yml to configure ActionMailer. Here’s what ours looks like:

production:
    delivery_method: :smtp
    smtp_settings:
      address: smtp.gmail.com
      port: 587
      domain: gmail.com
      authentication: :login
      user_name: info@expandrive.com
      password: password

Next, in production.rb makre sure to

require 'smtp_tls'

That’s it, you’re good to go.

If you want to set up any old Rails app [using Action Mailer] to send mail via Gmail, add this to production.rb

require 'smtp_tls' 
 
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.default_charset = "utf-8"
 
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:authentication => :login,
:user_name => "info@expandrive.com",
:password => "password",
}

Subscribe:

Add to Google
RSS
Try ExpanDrive

If you’ve heard of SSH then you need ExpanDrive.