Kûn Developer

Ruby, Rails, Emacs, and other cool stuff

Moved over to http://blog.kundeveloper.com/

Hey, Kûn Developer here. If you’re reading this is probably because you don’t know that blog has moved over to http://blog.kundeveloper.com/

Hope to see you there!

Reaching out to the Ruby Community

I’m not usually the type of person who reach out. I’m usually afraid of getting rejected or being ridiculous in front of my heros.

But one day I decided to close my eyed and try reaching out. Often enough people tells you to take hard things one step at the time, so I decided to ping my absolute favorite Ruby Character in the whole world. Yes … bold move for someone that claims to be timid, but the internet “wall” facilitates that a great deal (believe me).

So here’s the story. I was listening to The Ruby Rogues Podcast and Avdi Grimm commented that he was remote pairing with people all around the globe. So I went to his blog, scheduled a pairing session and a couple of weeks later I was remote pairing with him.

That what this article is about. I’d like to publicly thank the Ruby Community for it’s openness. It’s very fulfilling to be able to interact with your heros in such a direct way. That’s something one doesn’t seem very often.

After that enlightening pairing session, I attended Ruby Conf Argentina, where I met a lot of cool people, Steve Klabnik among them. So I invited him to participate in a Hangout with my local user’s group and, of course, he said yes. So after some email exchanging we had an awesome Hangout with Steve, who is a great open source contributor and a very active person on the community. Again, the Ruby community didn’t let me down. You can watch the Hangout here.

Continuing on the community adventure I came around two guys almost simultaneoulsy.

I saw a video about Xiki (which I’ll dedicate it’s own article in the future), I tried it. I entered the Xiki mailing list. And I saw a post by Craig Muth, it’s creator, who was offering pairing sessions to learn Xiki … and yes … I took one slot. I found out that he is an excellent person, and I keep in touch with him regularly.

I also enroled on a Rails course brought by Charles Max Wood (host of the Ruby Rogues Podcast). This story was a little more … “entertaining”. I took the course for two main reasons. First, I’d had direct mentoring from Chuck (reason enough) and second, I’d have a commitment to create a project from scratch and finish it. But faith wasn’t on my side (or so I thought). By the time I was working as a remote Rails developer on a local shop, but a couple of weeks after the course started, my work rules suddenly changed, and from one day to the next, I started working full time on site. Which changed my routine drastically. So I couldn’t make the best of that course. After it finished, one day I was feeling depressed, watching at the small square-shaped monitor on my cubicle and I decided to say hello to Chuck via Skype (and ask him for a favor 😉 ). One thing let to another and I ended up offering help on his projects. So now I’m a subcontractor for one of the coolest guys on the Ruby Community, host of my favorite show. Again .. Ruby Community didn’t let me down!

Should I go on?, ok! Last week I reached out to two gerar people of the community via Twitter. It all started as a joke, but I’m now scheduling pairing sessions with James Edward Gray II and Jim Gay.

And also scheduling a Hangout with Avdi Grimm for my local user group.

So, all that big speach was just to encourage you, dear reader, to reach to your community. It won’t let you down.

All those people I mentioned above, are waiting for the community to reach out to them. Also am I. So please, be brave and take a leap of faith. You won’r regret it.

See you!

Avdi Grimm – Pairing is caring

Awesome presentation about the value of pairprogramming, by an expert on the topic.

Rails – Ordering through an association

Recently I had to present some information on an index page using Ruby on Rails. I decided to use Datatables (http://datatables.net/) for it’s ease of use. And it all worked perfectly.

One day, we decided on the team that the information on that table wold need to be paginated, searched and sorted on the server side (we predicted a lot of records going on that table). So I modified the datatables call to perform an AJAX request (more on that on a future post). But I found out that a couple of fields on the model where associations and I’d need to sort those fields using the correct attributes.

I want to share with you how to do it, because it came out to be very useful for me.

To keep it simple, let’s say we have two models:

A person model, which has a name an age and a pet.
A pet model, which has a name.

class Person < ActiveRecord::Base
  belongs_to :pet
class Pet
  belongs_to :person

So, ordering by person name or age is pretty damn easy:

Person.order("name ASC")
Person.order("age DESC")

This code will order all the people table’s data by name in ascendant order (line 1) or by age in descendant order (line 2). But when we try to order by pet name, we start seeing some errors:

 PG::Error: ERROR:  missing FROM-clause entry for table "pet"
 LINE 1: ...people".* FROM "people"   ORDER BY pet... 

The solution for this problem is using ActiveRecord’s “#includes” method.

Person.includes(:pets).order("pet.name DESC")
# => #<ActiveRecord::Relation::ActiveRecord_Relation_Person:...>

I hope this was as useful for you as it was for me.

See you

About this blog


Federico here, writing the first post of this blog.

I decided to explain in a couple of words the meaning of the title, because I imagine that it will be the first question anyone that reads this will have.

A couple of years ago (about 10) I decided I was going to write a science fiction book. I started it and one thing led to another … and, you know how this is. Now I have one written book in Beta version and 4 more on the back of my mind.

How does all of this have anything to do with the title? In the books world, there are 3 races (a race in there is like a soul … it’s a long story, don’t let me go there). All this Races where named like Kûn Something (Kûn is the name of that kind of soul …. yes, yes, over there there are kinds of souls … really, please, don’t let me go there).

When I tried to find a name for my blog, after lots of time, the name came to me as “Kûn Developer” … which turned out to be the best name I could ever find.

So there … that’s the weird story about the name of this blog. I hope you enjoy the contents!

See you on the next post

Post Navigation