Archive for the ‘ruby on rails’ Category

Distressing times for the Rails community

Thursday, April 30th, 2009

Things like this sadden me: Mike Gunderloy resigns as a Rails activist, no longer wishing to be a public spokesperson for Rails. This is a great loss for the community.

Things like this disappoint me: the attitudes of a few people cause a tainting on the entire community. Even if David Naughton has misunderstood the issue, it is clear that the whole debate has had a negative effect on the Rails community.

Unexpected pornography at a professional conference surprises me, shocks me a little. I wonder whether Matt Aimonetti, at any point during the preparation of that presentation, thought "This is likely to offend some people", and if so, whether Matt decided not to care.

The refusal of some Rails representatives to even acknowledge that there is a problem angers me. Yes it was edgy. Yes it was creative. It can be those things and still be offensive. "Creative" is not a synonym for "acceptable". Offending people is a big deal. The unpology "I'm sorry that you happened to be offended" is a world away from apologising for having been the cause of offence.

It is not a person's fault for being offended. Without wishing to be a Bible-basher, there is a lot to be said for this little nugget of advice:

"If it is possible, as far as it depends on you, live at peace with everyone."

You can't please everybody all the time, but there are basic precautions that you can take, and when you have made a mistake, you can take responsibility for it and apologise for it.

I think that is the end of my rant, and i hope i will have nothing more to say about it.

* * *

I would like to say publicly, again, that i appreciate my job so very much. I am extremely lucky to work in a family-friendly, vibrant, fun, laid-back yet totally professional environment, doing a job that i enjoy with my whole heart. I don't expect expect to be discriminated against, nor do i expect any special treatment. I receive precisely the appropriate amount of respect and admiration that i deserve based on my skill as a programmer. I am extremely grateful for it.

Here's a picture of me loving my job today, along with some of my colleagues, sat on the picnic bench in the sunshine: yfrog.com/4o8a2j :)

* * *

Sort of related to the rant, i have been wondering tonight where my opinions come from. Different people have different opinions, and i can read and intellectually understand varying stances, so what is it that sways me so strongly in one particular direction? I have an opinion on almost any given topic, but i don't always know what it is that makes me feel that way.

I find the various out-of-control tram hurtling down a track thought experiments quite interesting in terms of moral dilemmas to which people often have a strong opinion, yet cannot quite explain why. Ethics and morals are curious subjects.

CouchDB and data storage

Friday, April 10th, 2009

Alexander Lang has written a great article about why CouchDB is not compatible with ActiveRecord, and why you should not try to coerce CouchDB into mimicking a relational database. It really is a very different thing altogether: The case of ActiveRecord vs. CouchDB

In my experience of CouchDB i first tried out ActiveCouch because of my familiarity with ActiveRecord. I soon came across problems because it was trying to make CouchDB something that it is not. As i exclaimed at the time, "LOL. ActiveRecord this is not!"

I had far more success with couchrest which is a much closer CouchDB wrapper, enabling CouchDB to be used as it's intended: as a RESTful interface with map/reduce views.

Domain-Driven Design

Recently i have been reading Domain-Driven Design by Eric Evans. Through reading it my understanding of Rails - and web programming - has completely turned around. My thinking used to be entirely database-centric. I saw Rails as little more than an easy access into the database. For ages i didn't even realise that you could have models that weren't connected to a database table!

Now my thinking has changed and i consider the primary focus to be the domain model. I think about the classes and the design patterns that apply to them. I consider how they fit together, how they communicate with each other, and the boundaries between the core domain and subdomains. In my mind, the database has gone from being the most important thing to being just a method of persistence for the data in the domain model.

When you think of things this way round you are less likely to get hung up on the differences between ActiveRecord and CouchDB. You work out your domain, design the classes and then think about the most appropriate database platform to support your model.

Update: I've just come across a useful article that provides three methods to achieve a has_many relational structure in CouchDB. CouchDB "Joins" by Christopher Lenz.

Attachments with CouchDB and Rails

Monday, December 15th, 2008

In response to my recent CouchDB on Rails tutorial, somebody asked the following question:

Let's imagine, that you want to store a picture of grandma along with her contact-info - how exactly would I do that?

Well, Stf, here's the answer, with a picture of my actual grandma to illustrate!

Attachments with CouchDB and Rails

(more…)

Christmas cards: DONE!

Sunday, December 14th, 2008

Wow, what a relief! I finished writing my Christmas cards at 18:30 this evening. I am so glad of the idea to print labels. Thanks to Rails, CouchDB and my pdf_label_maker library, it was much easier than usual. I just sat down and forced myself to get through them all, pausing only once to take a photo:

Half way through

Note the chocolate, ruler and calculator, heheh! I actually bought some cheapo labels from the £1 shop … they weren't even on an A4 sheet, which meant i had to do quite a lot of measuring and trial and error. But i'm so pleased with the result - they look so neat, as opposed to my handwriting which gets terrible whenever i have to write a lot in one go.

Christmas cards: DONE!

Yes, i actually did write a Christmas card to topfunky! ;)

The best thing is … if i keep the database updated during the year, i can print them all out again next year! I'm definitely going to keep developing it, and learning more about CouchDB on Rails in the process.

A hurrah moment!

Friday, December 12th, 2008

Not really part of the "CouchDB on Rails" series, but i thought i'd post it anyway …

I have successfully entered the addresses for Christmas cards into my database and generated PDF output that should be of the right layout to print onto Avery labels. Sweet! The really awesome thing was, i started to forget that i was working with CouchDB and it just felt like any normal Rails project.

I only know two label formats right now, and neither of them are the one that i actually want to use.

L7162 - too big:
L7162 labels

J8651 - too small:
J8651 labels

But the cool thing is, i made a little library, pushed to GitHub of course! It is not CouchDB-specific. It's probably not even Rails-specific, although the examples are. Perhaps some other people will contribute the dimensions of other label formats for me.

For those who want to know how i implemented this in the CouchDB application, here's the commit.

For those who are interested in the PdfLabelMaker library, here it is: pdf_label_maker.

My thanks to Nick Sieger for giving me the example code to begin from.

Update 14th December 2008: Success! Labels printed and Christmas cards written! :) See this post for more.

Y GIT IZ BETTR THAN X

Wednesday, December 10th, 2008

LOLCATZ IN UR GITHUBZ!

There is really no need for this: lol.whygitisbetterthanx.com but it is so funny!

GIT WILL ALLOW U 2 HAS MULTIPLE LOCAL BRANCHEZ DAT CAN BE ENTIRELY INDEPENDENT OV EACH OTHR AN TEH CREASHUN, MERGIN AN DELESHUN OV DOSE LINEZ OV DEVELOPMENT TAEK SECONDZ.

Aimee's law of LOLCATS: Anything you push to GitHub will, in time, become translated into LOLCAT. This is inevitable.

P.S. I've just had a look on GitHub, and the page has now been translated into 11 languages. :) Sed ankoraŭ neniu estas tradukinta ĝin en Esperanton. Mi pensas, ke Esperanto devus esti la sekvontan tradukon. "Kial Git estas pli bona ol X" :)

CouchDB on Rails (part 8 of ?)

Wednesday, December 10th, 2008
  1. An introduction to CouchDB
  2. Installing CouchDB
  3. Experimenting with CouchDB's web interface
  4. Integrating with Rails using ActiveCouch
  5. Integrating with Rails using RelaxDB
  6. Getting to scaffolding using RelaxDB
  7. Installing CouchDB from Subversion source code
  8. Trying out couchrest and topfunky's basic_model

Some time has gone by since i last used CouchDB and one method seems to have bubbled up to the top as a good one to use. It is couchrest, helped along by topfunky's basic_model wrapper. Today i am going to have a little play with them.

I have been meaning to get back into CouchDB but to be honest, i was tired of the old CD Collection database, and i was waiting for some inspiration. Today that inspiration arrived! I need to write my Christmas cards by the end of the week. I was impressed this afternoon by my auntie's label printing system, and i decided i should do the same. I did some label printing last week at work, and i quite fancy making a nice little Ruby library for it.

I also think an address book is a pretty neat application for CouchDB as a document oriented database. It'll work quite well for people who have multiple email addresses, or multiple telephone numbers. The document for each person can expand as big as it needs to be without wasting database space for the people who only have one phone number.

I need to print these address labels by the end of the week. You know that if a programmer has 100 hours to do something, they will generally spend 99 hours figuring out how to do it in 1 hour! Let's go then! :D

(more…)

Rails on a netbook?

Friday, November 28th, 2008

I am here today to ask a question and then answer it. The question is: Can you run Ruby on Rails on a netbook? Specifically, an Acer Aspire One. My motivation is … since buying my netbook, i have completely fallen in love with it, and much prefer it to the desktop computer. I want to do as much as possible on the netbook. I don't think i'd spend a whole day coding on it, but just for quick little things it could be wonderful!

Now that MyChores is open source i really like this idea of code anywhere. Wherever i have my netbook and an internet connection, i can code! If there's an emergency bug needs fixing on MyChores, i could make the fix and push it. Or if i'm feeling lazy one Saturday morning there can surely be nothing better than a cup of coffee and coding in bed! ;)

So without further ado, let's see if you can put Rails on a netbook …

(more…)

Looking forward to Rails 2.3

Friday, November 21st, 2008

There are two things that i am especially looking forward to in Rails 2.3.

I use named_scope like all the time now since i figured out what they are and how useful they can be. I often find myself doing something like this:

named_scope :ordered, :order => 'surname ASC, first_name ASC'

Just so that i can append .ordered to any other named_scope and get my objects out in a sensible order. Well in Rails 2.3 we're going to have a default_scope

default_scope :order => 'surname ASC, first_name ASC'

Marvellous! :D

The other thing i'm looking forward to is the new super-slick render for partials. No more

render :partial => 'articles/article', :locals => { :article => @article }
render :partial => 'articles/article', :collection => @articles

Those now become the splendidly simple

render @article
render @articles

Thanks to Ryan's Scraps for explaining to me how that's going to work!

The joy of GitHub

Wednesday, November 19th, 2008

Who knew that coding could be such a social activity! I really like GitHub, with its ability to fork people's code base, apply your own changes, offer it up to be merged back in, see the difference logs, comment on the difference logs … ah, now that last one's genius!

Somebody happened upon this quiet little commit from DHH … yes, the DHH, creator of Ruby on Rails. The bright spark goes and posts it to Reddit, prompting the world and its duck to chime in with an opinion! It's quite funny reading through the comments, both on Reddit and on GitHub.

What does the commit do? Not a lot. It's what we call syntactic sugar: aliasing something in code as something else. It means we'll be able to do this:

['a', 'b', 'c', 'd'].third
=> 'c'

Of course, i have an opinion too. I can see why it could be useful, but i don't really think it is worthy of being in the Rails core code. I doubt i will ever use it. I also agree with the person who says it widens the gap between Ruby and Rails. When Array#first is available in Ruby, people will wonder why Array#second is not.

I do wonder, if anyone other than DHH had submitted this 'patch', whether it would have been accepted into core Rails.

After laughing at this thread over lunch today, one of my colleagues sent me an instant message:

Coffee.third?

I replied:

return true

I think it's good that people are looking at the commits, seeing what's going into Rails, and having their say about it. This is community-driven development at its best! Cheers, GitHub! :)

Update: DHH has responded! It now only goes up to fifth … but Array#forty_two has been added in as compensation! DHH calls it accessing "the reddit".

who-am-i
A web programmer in my mid-late-twenties, fanatical about open source, free software, loving my job working daily with Ruby on Rails, RSpec, Cucumber and Git.

I am very proud to have created MyChores.co.uk, an online team based tracking system for household chores and other recurring tasks.
Search



Recent tweets
Flickr