ruby on rails Social Media TechBiz WebApps

What the Next Rails Will Look Like

History repeats itself, yet it is obscure to the very people making it: innovators and inventors. Ruby on Rails was an invention that hit the scene in July of 2004 as a revelation. There was a video that promised that you could make a blog in less than 15 minutes that left many speechless.

When Rails hit the seen, my reaction was:

1. This is something that we should have been doing all along.

Books like The Pragmatic Programmer had been preaching what Rails was doing since the 1990s. Software engineers would half-heartedly code the “Rails ways” but never got around to building something like Rails.

2. I need less people on my web team.

It seemed that you could work with just a designer and get lots done. I didn’t have to go to IT as much as database issues. I could use generators and save hours of time.

3. That startup that seemed impossible now seems within reach.

I remember a young Chris Wanstrath at a Ruby meetup I hosted saying with a tired look in his face that he wished he was working in Ruby. He was at CNET / CBS Interactive at the time. He’s built the best tool for developers out there and I use every day.

That’s the past, now what’s the future?

The tough question to ask is, “What should we, as an industry, be doing that we are not?” The Rails philosophy was loudly yelling, “We aren’t doing DRY.”

It seems that there are 4 things that need to be done in the “next” Rails:

1. Mobile ready out of the box.

We should all be using CSS media queries and have the ability to support the mobile web. There are so many missed opportunities to retain users simply because mobile is still shockingly ignored.

2. Social Sharing out of the box.

This basically means that there has to be a standard for creating an API for APIs.

3. The backend will just look like an API.

Say good bye to complex SQL joins.

4. Designing tools with deep integration into the cloud.

Languages have been designed for CPUs in non-networked environments. This means that at a core-level, the next Rails will be SSL capable, e-commerce capable and ready to scale out of the box. Hints of this can be seen in Erlang.

Coding How-To ruby ruby on rails WebApps

Upgrade Your Rails Facebook App to SSL

On October 1st of this year, Facebook will be requiring that all apps on Facebook must support HTTPS (SSL).

I’ve provided a guide below which I’ve used for apps I’ve worked on that are Rails based.

This guide shows you how to change your Rails Facebook App into an app that supports SSL using Passenger and Apache2.

Step 1: Get an SSL cert or roll your own. made it very easy to add an SSL cert for just $15.00 / year.

I tried out my app out using a locally signed certificate which seemed to work just fine:

openssl genrsa -des3 -out server.key 2048
openssl req -new -key server.key -out server.csr
cp server.key
openssl rsa -in -out server.key
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

Step 2: Install and compile Apache 2

Get the latest version of Apache:

Configure and compile Apache:
./configure –prefix=/usr/local/apache2 –enable-rewrite –enable-so –enable-ssl
make && make install

Step 3: Configure your Rails app

gem install passenger

Step 4: Edit your Apache 2 config files:

Edit httpd.conf. For example:

LoadModule fcgid_module modules/
LoadModule passenger_module /Users/jimbarcelona/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.8/ext/apache2/
PassengerRoot /Users/jimbarcelona/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.8
PassengerRuby /Users/jimbarcelona/.rvm/wrappers/ruby-1.9.2-p290/ruby

    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all

Include conf/extra/httpd-vhosts.conf
Include conf/extra/httpd-ssl.conf

IPCCommTimeout 40
IPCConnectTimeout 10

# TODO: change this to production if you are on production
DefaultInitEnv RAILS_ENV development
SocketPath /tmp/fcgidsock

Edit extra/httpd-vhosts.conf:

  DocumentRoot /Users/jimbarcelona/rails_apps/github/
  ErrorLog /usr/local/apache2/logs/rails_error_log
  RewriteEngine On
    AllowOverride All
    Options -MultiViews
  RailsEnv development

Edit extra/httpd-ssl.conf:

#   General setup for the virtual host
DocumentRoot "/Users/jimbarcelona/rails_apps/github/"
ErrorLog "/usr/local/apache2/logs/error_log"
TransferLog "/usr/local/apache2/logs/access_log"

# needed for rails
Options Indexes ExecCGI FollowSymLinks
RewriteEngine On
RailsEnv development

AddHandler fcgid-script .fcgi

    AllowOverride All
    Options -MultiViews

Be sure to add your SSL certs in the httpd-ssl.conf too!

Step 5: Start Apache

# check syntax
apachectl configtest
# start apache
apachectl start

Step 6: Go to facebook and use https for canvas URLs

How-To ruby on rails WebApps

The Rails Console Makes Test Object Creation and Debugging Easy

I really like how the Rails console solves the problems of test object creation and debugging.

Usually, a web developer will push code to the webserver and hit shift-reload on the web browser. With the Rails console, you can avoid all that shift-reload madness.

If I wanted to create 10000 blog posts for testing, I could do something like this:

{ |i| Post.create(:title => “post number: ” + i.to_s, :body => “autogen Booyah!”) }

Through the console I can also do debugging pretty easily:

>> p = Post.find 888

And get this as output:

=> #

A lot of problems in Rails are just solved by running script/console and checking the values of certain variables that are pretty hard to get at through a web browser.

There is pretty much no limit to what can be done through the Rails console. Konstantin Gredeskoul, web developer and songwriter, has found a way to load session data through the console.

ruby on rails TechBiz WebApps

Mephisto: Blogging Software on Rails

Blogging software should meet four important criteria:
1) Easy import from a pre-existing piece of blogging software we’re not happy with.
2) Spam filtering protection in comments
3) Make it easy to add web analytics javascript tracking without deleting it during each upgrade.
4) Should make it easy to not look like Mephisto blogging software or WordPress or like generic blogging software.

Mephisto screenshot

Mephisto meets all four criteria.

Plus it leverages the advantages of Rails in that out of the box you can deploy to development, test and production environments. Also it integrates with no mess into shopify or any other Rails project that you might be working.

Hats off to Rick Olson(Development) and Justin Palmer(UI/Design) for making Mephisto along with “a bunch of other cool people.”