Why we use Rails for Client Projects.

Posted by Floyd Price Tue, 06 Jul 2010 17:44:00 GMT

At least 50% of the time a client will want us to use a specific technology (.NET or Java), this makes perfect sense as a lot of our clients are corperates who have invested a lot of time and money in a particular technology.

The great news for us, and the other 50% of our clients is that we choose to use Ruby On Rails whenever possible. The reasons are many, but a few of the more profound ones are:

Productivity

Thats right, we are about 2 (maybe 3) times more productive with Rails than .NET or Java, now this isn't because we are primarily Rails guys in fact I have spent many more years working with both .NET and Java than I have with Rails, the simple fact is that Rails gives us a head start as we get so much for Free.

This is profound in two ways, firstly and most obviously it costs the client less, and enables us to create better relationships. But this productivity gain also allows us to get functionality in front of the user quicker and as such we can identify requirement changes and fix bugs sooner, meaning we deliver better quality code first time.

Agile

We work in an Agile manor and while we can do this regardless of the technology we use, Rails lends itself to an Agile process perfectly.

Solid Design Patterns

Rails encourages the developer to employ consistant design patterns, the rails guys call this Convention over Configuration which promotes maintainable well tested code.

Separation of Concerns

Rails goes beyond Separation of Concerns by removing Concerns, Object Relational Mappers take out 1000's of lines of code that would take up 50% to 80% of the developers time, simple Routing patterns eliminate tones of boiler plate code.

The baked in support for Model View Controller means makes its easy to keep things in the right place.

Open

Over a 10 year contacting career I hit so many hurdles using web frameworks from commercial vendors, from the ASP.NET framework to JSF I found that whenever I wanted to bend these frameworks, they snapped! And the closed source meant that I was back to the drawing board having to invent an ingenues hack, Rails however is open source and the code (especially the rails 3 code) is well written and easy to extend (partly due to the Ruby language), I can easily bend it in any way I choose.

Database Agnostic

As I mentioned the Object Relation Mapper reduces a tone of code and save you even more time, but the abstraction from the database goes even further than that, A rails application written against MYSQL will work against any Database in production, in fact we have an app that is running on SQL Server for one client and Oracle for another, while we host it for other clients on MYSQL.

 

Just a few reasons why we use Rails, I hope you will too.

 


Jruby.com

Posted by Adrian Wed, 02 Sep 2009 14:48:00 GMT

We have aquired Jruby.com, and we intend to make it a useful resource for people who are interested in enterprise Ruby on Rails development. I'll explain some of our ideas here, so you can have some inkling of what to expect. We are open to any and all feedback.

We have written our latest business package, BrightSpark, in Ruby. This isn't much of a departure for us because we have quite a few Ruby on Rails projects in our portfolio, including CodeSpaces which is by far and away our largest Rails projects. However, it is the first time we have written a complete business package designed for deployment on our customers' servers in Rails.

One of the influencing factors in our decision to go this way was the ever-maturing JRuby. JRuby provides a wonderful bridge between Ruby and Java, and this opens up certain enterprise opportunities.

In our experience, Ruby gets a lot of of attention from forward thinking developers in enterprise environments, but it rarely gets any real traction. This is often down to lack of familiarity, or the perception that it is not a seriously supported language. Java, of course, is at the complete opposite end of the spectrum. Merging the two makes a lot of sense.

You would be amazed at how fast we can prototype new web applications in Rails. What would take several weeks of effort by a small team can often be accomplished in a few days with Rails. Not because it is magic, but because it is pefectly designed to enable rapid development of data driven web applications. This alone makes it a worthwhile tool for enterprise development teams -- even if it is only ever used as a prototype tool, being able to get ideas in to software form rapidly would positively affect the outcome of many projects.

So what's planned for JRuby.com? Well, as part of our work preparing BrightSpark for easy installtion, we're packaging a complete JRuby server stack. This will include an application/web server (Tomcat, Glassfish or TorqueBox), a database (MySQL, Postgresql) or adapters for commercial databases (SQLServer, Oracle, DB2) and an app store style deployment system for distributing applications (we've currently prepared two free applications; WikiWikiNoteBook and WikiWikiTaskList -- these are available as stand-alone Rails apps in our Labs section of the website).

We're also recording training videos and writing guides that help .NET and Java developers get up to speed on Rails fast. Any competent developer could learn Rails in little over a week, and with the right kind of help it could be even quicker.

This is all planned to arrive some time around the end of September. We're a small ISV, and we have a couple of other projects on the go so this date might slip a little, but we're really keen to get this started and make it a genuinely useful resource.


Debugging your rails controllers with JRuby and Mongrel

Posted by Colin Fri, 24 Jul 2009 07:48:00 GMT

If like me you think that NetBeans is a superb IDE, but quiet often for some unknown reason end up firing up TextMate to fix a bug or add a new feature, only to realise you lose all of the lovely debugging tools that come with the IDE. Well we can take a step in the right direction by allowing you to break out of your controller actions and into a irb console..

First things first we need a java implementation of ruby-debug-base. Fortunately one exits at http://rubyforge.org/frs/?group_id=3085 but it is not installable remotely so download the latest version of this file into a local directory (at time of writing this was ruby-debug-base-0.10.3.1-java.gem)

Fire up terminal and go to the directory that contains the gem file and enter the following

jruby -S gem install ruby-debug-base-0.10.3.1-java.gem
we also need to install the native ruby-debug gem as mongrel requires this to run with the –debugger swtich
ruby -S gem install ruby-debug

O.K with that all installed successfully we can now go ahead and start up our mongrel instance so go to your rails app and issue the following command, to start mongrel

jruby --debug -S script/server --debugger
Now in your controllers, you can create a breakpoint by entering debugger at the point you wish. This will cause the server to break into an irb session. From here you can write any code to inspect your controller you want. Be careful though as you are just issuing ruby commands so Model.destroy_all really will destroy all :)


Using JRuby LDAP to authenticate users with rails

Posted by Colin Tue, 21 Jul 2009 09:20:00 GMT

Many enterprises have an Active Directory infrastructure setup. Wouldn’t it be nice if your jruby app could exploit this already in place infrastructure to authenticate your users. ruby-net-ldap has been around for a while and allows users to do exactly this with MRi ruby and now thanks to Ola bini it is now possible with jruby.

First things first, we need to install the gem,

jruby -S gem install jruby-ldap

once the gem has been installed we can then fire up a console, execute the following command in your rails app directory

jruby -S script/console

once the console is booted enter

   require 'ldap'
   conn = LDAP::Conn.new(host="IP Address of your server", port="LDAP Port, typically 389")

this should then return you a connection object which we can use to now use to bind to the server and form there on search the directory tree. to bind to the server we simply supply some credentials. NB: I had a problem initially as some of the usernames contained periods(.) i.e. foo.bar and this caused a few problems for these accounts, the solution was to fully qualify the name (foo.bar@componentworkshop.com)

  conn.bind("username","password") do |bound_conn|
     conn.search("cn=Users,dc=domain,dc=com", LDAP::LDAP_SCOPE_SUBTREE, "(&(objectclass=person))",["name","mail"]) do |entry|
        puts "#{entry.inspect}"
     end
  end

when ran this code will render each entry that the search has found, firstly it creates a binding which authenticates you on the server. We then pass a block to search the LDAP tree. The search method takes a few parameters, for info about these parameters have a look at Suns documentation

Now we have verified, that everything is setup and working. We can go ahead and use our new found wisdom to authenticate users from our login controller. The following code provides an example on using jruby-ldap to authenticate the users, and then add them to a user model if they do not already exist in the database.

def authenticate
 attrs = ["name","samAccountName", "cn", "mail", "department", "manager"]

     conn = LDAP::Conn.new(host = "127.0.0.1", port = 389)
     conn.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)   

     domain = "foobar.com"

      conn.simple_bind(login + "@" + domain, password) do |conn| 

        conn.search("cn=Users,dc=componentworkshop,dc=local", LDAP::LDAP_SCOPE_SUBTREE, "(samAccountName=#{login.to_s})", attrs) do |entry|

              user = User.find(:all, :conditions => ["login = ?", login]).first

              if(!user)
                user = User.create!(:name => entry.vals('cn').to_s, :login => entry.vals('samAccountName').to_s, :email => entry.vals('mail').to_s)
              end

              return user;
           else
             return User.find(:all, :conditions => ["login = ?", entry.vals('cn')]).first
           end
        end           
      end
end

About

We are a small British company that produces business-oriented software and solutions. These articles are a product of our daily work - information that we think might be useful to share. We hope you find them useful.

Our Software

These are some of our products. Several are open source, some are web-based and others are proprietary:

Categories

Archives

Syndicate

ml> ._trackPageview(); } catch(err) {} ml> l> pageTracker._trackPageview(); } catch(err) {} ml> ._trackPageview(); } catch(err) {} ml> l>