Archive for January, 2009

Communism vs. Capitalism

“Owners of capital will stimulate working class to buy more and more of expensive goods, houses and technology, pushing them to take more and more expensive credits, until their debt becomes unbearable. The unpaid debt will lead to bankruptcy of banks which will have to be nationalized and State will have to take the road which will eventually lead to communism.”
[Karl Marx, 1867]

Ruby on Rails – Tools I Use

Going with the hype, I am coding in Ruby on Rails and exclusively on a Mac.

As a text editor I am using TextMate. It was love at first sight (although shared) – I know, we are talking about community here. But as many of us, I would like to see more often updates and at once that pending version 2. It is something there which says that a version increment will make us much more happy. I have a feeling it is loosing slowly its vibe. For instance: Peepcode is releasing a screencast episode about Emacs, and I am also seeing more and more blogs talking about switching to either Emacs (Carbon or Aqua) or to MacVim.

CSSEdit 2 is filling my coding gear and it helps a lot in cleaning my templates. I am a dirty hand coder in the way I am using quite often something like <div style=” …. “> directly into my code, pushing only at the end for what I need to a style sheet.

I discovered git once with Rails and since it became my right hand in versioning. I never believed it can be so easy, doesn’t matter if you are online or offline, you are alone or working along with a team. More, I agree it is more productive to have that infinite hexa number instead of 1, 2, etc as your file/project version number, because you just code, don’t tend to compare. And because I love luxury, I am using a micro account with github. Yes, I have my own secrets there, too ;)

Ticketing and organizing my staff – I am into a personal level with the lighthouse. And the Lighthouse Keeper is giving me enough support whilst offline.

What about you?

Coding Aloud – Restricting your users to edit other’s profile

restful_authentication plugin made its way to my projects as the “de-facto” authentication system in my Ruby on Rails projects like w2task or gistate.com. I would not insist on how to install it, as it is well explained on its home page at github.

What I want to show is that in particular instances we may not like that one user can access and modify other user’s profile. For example if I try to edit my profile, the URL will end in something like users/2/edit and if I would change it to users/1/edit then I am able to modify this user – most often an undesirable fact.

Here is my workaround:

app/controllers/users_controller.rb
  # ...
  def edit
    if params[:id].to_i == self.current_user.id
      @user = User.find(params[:id])
    else
      flash[:error] = "Not allowed!"
      redirect_back_or_default('/')
    end
  end
  # ...

That’s pretty much everything I need to change.

What is your preferred solution? Are you doing these tests into a – perhaps – before_filter?

w2task Challenge

I would like to introduce my latest project w2task - a web application written in Rails.

w2task challenge

It is a task and time management web based software. At this point, a registered user can create its own business (company) and define a series of projects. Then, the user can record its own efforts and attach them to a particular project. The sidebar (Efforts Bar) gives a quick statistic regarding the number of efforts and total timing. Also, by clicking on a particular project you may get the timesheet of the particular month.

You may well give it a try, here is the link: http://w2task.com. Don’t hesitate to tell me your opinion about it, right here as a reply to this post. You may me as harsh as you want, it is constructive and ultimately this blog is moderated :) .

Be warned, this web app is still in its early, early development stages.

To better understand the philosophy behind this application, the strength and the weaknesses of the application, allow me to tell you in few points a bit of my history with Rails:

  • January 2008 – I’ve bought my first Rails book Agile Web Development with Rails, but I didn’t have enough time to practice it that Rails, turned 2.0 and broke the compatibility with 1.x versions. I remember the headaches regarding the scaffolding, so I abandoned my Rails path.
  • May 2008 – I’ve make up my mind and bought the third edition of the above book and start again with Rails at a low pace.
  • October 2008 – my friend Hossein asked me to join in a web project with a real estate portal. I thought it is the moment to put my knowledge into practice and this his how gistate.com got wind. Ok, the real estate market is down now (dec 2008 – jan 2009), but gistate.com shines ;) .
  • November 2008 - Dubai Hacking Night – where I meet again my heroes: the SpinBits guys which encouraged me to learn Rails. I have shown to Rida a sketch of w2task (a scaffold and some CSS files) – a Ruby on Rails practicing project and he asked me to promise that I will present it on DemoCamp 4, which should be in mid January 2009.
  • December 2008 - I have closely followed 37signals blog and read their book - Getting Real. Truly inspiring, and I am thinking to copy their business model.
  • 2009 – here we are.

Wow, getting long with this post. However, for the future, I have a lot to say and I hope it will be of interest for my blog readers, as I will fly along the Rails.