Posts Tagged ‘rails’

Rails is moving from SVN to Git

Thursday, April 3rd, 2008

A year ago I was frustrated over Rails’ close ties to Subversion. But as Rails is moving from SVN to Git, the future is looking bright. The only bastion left I can think of is RubyForge.

Things I Have Actually Used

Monday, March 31st, 2008

Robby Russell is a constant source of information on Ruby and Rails, I have used his instruction on how to set up Rails and PostgreSQL on Mac a number of times. It is therefore fun to see that I have actually used 3 out of the 5 things he wants to know more about::

RSpec User Stories

We were very early adopters of this one, we started using it the same day it hit trunk in a useable form. Everyone should start using it today – I cannot speak highly enough of it. The only thing I miss is a Fit-style table approach to rules, but I have my own thoughts about that one.

Using Selenium with RSpec

We have used the now outdated spec/ui library at WeMind. Today we use RSpec Stories almost exclusively for acceptance testing. My position is to use Selenium only where you really need it, for example to test Javascript functionality.

JQuery

I have used it for the dynamic hiding of speaker info for Agila Sverige. Not at all enough to judge a library by, but it feels a lot sweeter than Prototype/RJS.

JSSpec (BDD for Javascript)

Yeah, I wanna know more about this as well.

Using the Google Charts API with Rails

Same here.

Other than that I would love to try out:

  • Seaside – I have dabbled with it but nothing worth mentioning.
  • CouchDB

The Lazyweb

Thursday, March 6th, 2008

Yesterday I twittered that I was trying to find a version of Ruby that both cc.rb and Rails likes. Last night, Wordpress plugin Twittertools posted yesterdays twitters to this blog. And this morning, I have an answer from Alexey Verkhovsky what the good versions are. Gotta love the lazyweb.

How To Automigrate the Test Database Using Merb, Datamapper and RSpec

Saturday, February 16th, 2008

I am creating a small site using Merb, DataMapper and RSpec, all in all a very enjoyable experience. I did however have problem getting the test database to be automigrated when running the specs, as I am used to in Rails.

As Google did not help, I turned to #merb on IRC, and got immediate help.

Two alternatives:

  1. Run rake MERB_ENV=test dm:db:automigrate before running rake specs
  2. Insert DataMapper::Base.auto_migrate! into your spec/spec_helper.rb

Big thanks to topfunky, afrench and jdempsey for the help.

git Is Winning The DVCS Battle With git-svn

Saturday, February 9th, 2008

I’ve been using distributed version control for over a year now, and if it is up to me, I will never use a centralized VCS again.

When I evaluated the alternatives last year, I choose Mercurial as the DVCS we are using at WeMind. The reasons were:

  1. Usability – git was quite obscure back then
  2. Speed – bazaar and monotone was quite slow
  3. Large enough uptake – OpenSolaris and Mozilla started using Mercurial at the same time.
  4. Runs on all platforms, if we ever employed someone who wants to use Windows
  5. Built in Python which could be a good think if I ever wanted to extend it

A year later we are happy with Mercurial, but the landscape has changed. In particular I am seeing a huge growth of people using git, especially within the Ruby community. Which in itself is something I am happy about.

The biggest reason I see for git’s resurgence is git-svn. It allows people to start using git locally while still having Subversion as the backend, and when everyones ready the switch is easy.

There is a hgsvn in the Mercurial world, but it is read only, so you cannot push your changes back to Subversion. I strongly believe that the Mercurial community should focus on this if it wants to regain its momentum.

Git still has weak support for Windows, but that seems to be a non-issue in the Ruby world.

I am pretty agnostic about which DVCS will be the dominant one. The most important thing is that people are moving away from the centralized VCS’s.

For a great post on the subject, read what Dave Dribin has to say about it

Tool Support Should Be Loosely Coupled

Monday, December 17th, 2007

I just read the following in a month old post on the RSpec list:

As someone who uses an IDE, I find dealing with multiple SCMs is a real pain, and one of the cool things about Ruby has been that (traditionally) nearly everything’s in Subversion

It might be that Rails will have hard time keeping up with new stuff, both technically and culturally, since it tied really close knots with everything that was cool 2005.

Choice Is Good

Thursday, December 13th, 2007

I was happy to note that Dion Almaer commented on my blog post on Merb. Dion is one of my favorite bloggers/podcasters and I value what he writes highly.

But I disagree with him on this one. The problem with using Java for web application development was never one of too much choice. In fact, it was because of that choice that Java became a player in the server side market at all. Sun alone never had the answer to what was needed for server side development, instead the open source world stepped in and made incremental corrections.

The same thing is happening to the Rails world. The core team cannot create a framework that is a one-size-fits-all. The initial Rails proposal is great for a large number of webapps, but it is other things around it like plugins and JRuby that is making Rails a viable choice for all.

My Java tools of choice was usually Tomcat/Jetty, FreeMarker, iBatis, WebWork tied together with Spring or PicoContainer. What I hated was having some frankensteinian-enterprise-architect-design-by-comittee-lets-not-be-different stack forced upon me with a fullblown J2EE server, EJB’s, Struts or the JSF monster, sprinkled with an Eclipse-only development environment. And I hope dearly that Rails development is not going the same way where people question you on your choice of tools and wonder why you are not using MySQL and TextMate like the rest.

There is one choice that I do not miss though – directory layout. I am truly happy every time I do not have to choose it.

Instead of not having to choose, the most important difference I’ve experienced is that Java as a language together with the Servlet/J2EE spec induces a lot of accidental complexity, which is almost non-existent in the Ruby/Rails world. It is that which enables the increased velocity many development teams experience when switching to Ruby.

Rails Marketing Is Really Good

Saturday, December 8th, 2007

DHH’s post about the Rails 2.0 is incredibly well written. It is almost as he is showing off a unknown past as a PR agent when he talks about Rails not supporting commercial databases out of the box:

But that doesn’t mean the commercial databases are left out in the cold. Rather, they’ve now been set free to have an independent release schedule from the main Rails distribution.

This sort of well formulated marketing has been known to render some sour remarks from the rest of the open source web framework world. My belief is though that when they ask themselves “Why are people so attracted to Rails, my framework of choice is just as good or even better”, sentences like the one above are probably a large part of the answer.

Merb, Leaner And Meaner Than Rails

Saturday, December 8th, 2007

I have used Rails on a daily basis for almost a year now, and before that I was a night time hangaround. While I am definitely a happier programmer using Rails than anything built on Java, I still feel that it can get better.

First of all I want more things to be plugins. And really, they should not be plugins at all but gems instead.

Why plugins? We use RSpec instead of Test/Unit, HAML instead of erb and are seriously looking into JQuery instead of Prototype. And of course, we are using Mercurial instead of Subversion. All of this is of course possible to use in Rails, but a lot of things are sort of made for the default choice, such as generators generating tests, and plugins having the -x switch for Subversion. And I am pretty sure that this is the way DHH wants it.

So, when 2.0 is now released, I see that the Rails community as a whole does not see the same problems as I do. If they did, they would have done more like the stuff above, instead of sexy migrations and ActiveResource.

This is where Merb becomes really interesting. I have looked at it before not understanding its value, but now I see a framework that does everything I want Rails to do. Gems as plugins and very agnostic about templating languages, Javascript frameworks and even ORM frameworks – almost a heresy in Rails. I will definitely think about using it instead of Rails in the future.

Delphi and JBuilder as role models for Rails development?

Thursday, September 20th, 2007

Chatting over a beer with Ola Bini last year, we discussed the possibilities for JRuby. My dream was to run a Ruby IDE on top of JRuby to get a Smalltalk like environment, because Smalltalk is still the best programming environment I have ever used.

Now that 3rdRail, running on JRuby, is released, should I get my hopes up? Some people are actually very excited about it, but when Delphi and JBuilder are referred to as some sort of pinnacle of development it seriously makes me wonder.

Where is IBM in Rails?

Thursday, September 20th, 2007

I have absolutely no clue as to why David Heinemeier Hanson would hold any suspicious thoughts toward Sun. To me, given the big boys in the playground, they are the good guys. But reading it made me realize that I have not heard of IBM in a very, very long time.

Big Blue was quite quick to join the Java bandwagon, remember VisualAge for Java? But in the new world of dynamic languages IBM, apart from a few developerWorks articles, is not to be heard from.

And this from a company who once was a strong proponent of Smalltalk? In my mind, if there is a mystery man, he and his cat is sitting in an IBM campus somewhere.

Not speaking at RailsConf Europe

Friday, June 15th, 2007

I just got a mail confirming that I will not speak at RailsConf Europe this fall. I had submitted a proposal named “Version Control in Rails using Mercurial” which was going to show the benefits of using a distributed version control system when developing a Rails app. My opening line would have been “Hi, I am Marcus and I have been Subversion free for six months”.

For some weird reason, so many people in the Rails community – and the open source community as whole – still talk about Subversion as something great. It is not. Subversion is decent at best if you are comfortable knowing that you are using second or third best tools, but believe me, it is a crap choice knowing the alternatives in distributed version control.

I really wanted to point all this out to the a larger audience so that we maybe will move beyond the Subversion centric mess which is the Rails community today. Oh well, maybe next year.

For a very entertaining and opinionated view on version control systems, watch Linus Torvalds most awesome presentation on Git at Google.

Stockholm is not Portland

Friday, May 18th, 2007

Sitting in Stockholm reading blogs, it feels like being home on a friday night knowing that there is a great party going on and you are not going.

Rails, PostgreSQL and Time

Wednesday, May 9th, 2007

I just noticed that the mapping between PostgreSQL’s Time Without TimeZone column type maps to Rubys standard Time class. Which gives the following behavior in script/console:

   >> t = TimeEntry.find(1)
   >> t.time
   => Sat Jan 01 23:00:00 +0100 2000
   >> t.time = Time.now
   => Wed May 09 19:02:07 +0200 2007
   >> t.save
   => true
   >> t = TimeEntry.find(1)
   >> t.time
   => Sat Jan 01 19:02:07 +0100 2000

Am I very anal to find this … sloppy?

has_many :through and callbacks

Friday, April 27th, 2007

Reading this a little bit earlier would have saved me a lot of time. In short: callbacks such as :before_add does not work with has_many :through, and the documentation does not tell you that. To get callbacks, add them to the join model.

RSpec, Autotest and views

Tuesday, April 17th, 2007

The current incarnation of autotest seems to assume that you are using integrated views. If not, you can modify the rspec_rails_autotest.rb file to run the view specs as well:

  # when %r%^app/views/layouts/(.*)\.rhtml% then
  #   ["spec/views/layouts/#{$1}_spec.rb"]
  when %r%^app/views/(.*)\.rhtml$% then
    ["spec/views/#{$1}_view_spec.rb"]

Your view spec must be postfixed with “_view_spec.rb” for it to work

Update This works out of the box now.

Autotest 3.5.0 and Growl

Friday, April 13th, 2007

Autotest 3.5.0 is out, and the result given from Autotest is no longer a String, it’s an array of strings. So if you still want Growl to function properly just modify the .autotest slightly:

module Autotest::Growl def self.growl title, msg, img, pri=0, stick=”" system “growlnotify -n autotest –image #{img} -p #{pri} -m #{msg.inspect} #{title} #{stick}” end Autotest.add_hook :ran_command do |at| output = at.results.last.slice(/(\d+)\s.*specifications?,\s(\d+)\s.*failures?/) if output =~ /[1-9]\sfailures?/ growl “Test Results”, “#{output}”, ‘~/Library/autotest/rails_fail.png’, 2 #, “-s” else growl “Test Results”, “#{output}”, ‘~/Library/autotest/rails_ok.png’ end end end

RSpec and Autotest

Friday, March 30th, 2007

I am getting all parts of my Rails development environment settled. In addition to vanilla Rails, I am currently using RSpec, Selenium and Autotest. I am seriously considering Haml and Sass as well.

When googling arounf to learn more about Autotest, I realized that people are using together with Growl. It works out-of-the-box with Test::Unit, but RSpec needs a little tweaking. I took the basics from here and modified to my liking. The following is what my .autotest looks like.

module Autotest::Growl
  def self.growl title, msg, img, pri=0, stick="" 
    system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{stick}" 
  end

  Autotest.add_hook :ran_command do |at|
    puts "at: '#{at.results}'"
    output = at.results.slice(/(\d+)\s.*specifications?,\s(\d+)\s.*failures?/)
    puts "out: #{output}"
    if output =~ /[1-9]\sfailures?/
      growl "Test Results", "#{output}", '~/Library/autotest/rails_fail.png', 2 #, "-s" 
    else
      growl "Test Results", "#{output}", '~/Library/autotest/rails_ok.png'
    end
  end
end

When It Just Doesn’t Work

Thursday, February 22nd, 2007

When everyone else is writing songs about their love for GMail, I am reverting to old school mutt. It is simply the fastest way to read and manage large amounts of mail (The Rails mailing list comes to mind).

However, the default install did not work out for me, it mishandled international characters and formatting which made it unusable. After trying a bunch of options it finally came down to this:

port install mutt-devel -ncurses -pop -imap

Now, of course pop and imap had nothing to do with it, but I am using the most excellent offlineimap so I do not need them.

Javaforum in Stockholm Wrap Up

Wednesday, November 22nd, 2006

I spent yesterday evening at Javaforum. Ola Bini held a great presentation of JRuby that really showed what can be accomplished today and what we can expect in the future.

Ola is not only an über hacker, he is a great guy too. When asked what work is done with Ruby in Sweden today, he was kind enough to mention the work we’ve done at Valtech with Rails, which of course got him a well deserved beer later.

The guys from Interface 21 did a so-so job presenting Spring AOP. I might be biased as I have been in AOP-land and left it, but in my opinion their presentation skills were far better than the actual content.

During after-beer Ola and I discussed the state of Java and agreed that the greatest part of the Java platform is the JVM. It will most probably survive Java the language and be a platform for a multitude of languages. It was therefore funny to read Mike Bowlers blog post today about exactly the same thing.

All in all a good evening.