Sep 03

I’m am still captivated by the perfect, simple CMS solution in Ruby/Rails (I’ll take another framework too). There are some fantastic projects out there, browsercms.org for example. But posts like THIS , really drive home the point. If Wordpress is so well suited for a simple site and/or blog, why not just use it? Igvita demonstrates easy Rails integration with Apache rewrite rules.

There are others out there stating the same thing: while Rails can be used to create a CMS, a developer’s time is better spent solving business rather than reinventing the wheel in Ruby to keep the whole project/code under one umbrella. And at my current gig, we are starting to retool for this paradigm. Rails and Sinatra apps are purely business focuses and super light weight. These service applications can them be glued together via ESI, rewrites, or Wordpress for consumption. In effect, your complex web app is assembled at request time from a set of simple web services. Here is some mock code to demonstrate:

wordpress_template.php
//some more wonder wordpress stuff
<?= include_rails_service('http://service.app/user/profile',ESI_INCLUDE) ?>
//some more wonder wordpress stuff
<?= include_rails_service('http://service.app2/events/weeks/2',SERVICE) ?>
//end of wordpress.php
...
//function included elsewhere
function include_rails_service(service_url,type){
//could return any of following for the resource url
 switch (type) {
  case ESI_INCLUDE:
   return "<esi include ='" + service_url + "'>";
   break;
  case SERVICE:
   include service_url;
   break;
  case AJAX:
//javascript include with service js, doing doc.write
}
}

The point is Wordpress doesn’t know about Rails and Rails doesn’t know about Wordpress. Keep them seperate, keep them simple and make life better.

Tagged with:
Aug 10

When working with Sinatra + ActiveRecord + MySQL running on the venerable Thin server, you are probably going to see the error after 8 hours(MySQL default connection timeout): “Mysql::Error: MySQL server has gone away” message. The resolution is pretty simple:

class NewApp < Sinatra::Default   

  before do
    ActiveRecord::Base.connection.verify!
  end
...
end #end of Sinatra class

I created a Lighthouse ticket before I discovered the resolution. There are also more technical details here: https://thin.lighthouseapp.com/projects/7212-thin/tickets/101-activerecord-connection-does-not-reconnect-when-using-thinsinatra-but-works-fine-with-just-sinatra#ticket-101-4

Tagged with: