Archive

Posts Tagged ‘ruby-on-rails’

MySQL gem doesn’t work after upgrading Ubuntu

May 6th, 2010 Petros No comments

I upgraded Ubuntu 9.10 to 10.04. Everything was cool. I tried to work on a Rails project I am involved by issuing the command rake db:migrate to update the database.

I was getting the following error:

Error: uninitialized constant MysqlCompat::MysqlRes

Then I uninstalled the mysql gem and tried to install it again only to get the following error:

Building native extensions. This could take a while...
ERROR: While executing gem ... (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.

Then I issued the following command:

sudo apt-get install libmysqlclient-dev

and then installed mysql gem and it installed with no problems. Finally, rake db:migrate worked again.

Categories: tips Tags: , , , , ,

Rails: url vs path

September 21st, 2009 Petros No comments

I was wondering why some people are using _path and why some use _url. For example, if you have a Post resource you can write the following in your view:

<%= link_to 'List of posts', posts_path %>

or the following in the controller:

redirect_to posts_url

Why should I use _url in the controller. I have used _path and it seems to work.

This is an explanation I found in a forum and I quote:

*_path are for views because ahrefs are implicitly linked to the current URL. So it’d be a waste of bytes to repeat it over and over. In the controller, though, *_url is needed for redirect_to because the HTTP specification mandates that the Location: header in 3xx redirects is a complete URL.

Categories: tips Tags: , , ,

Volunteering

September 1st, 2009 Petros No comments

Volunteering to non-profit organizations or to open source software projects is my second deed (2-deed).

I started this activity in June 2009 by becoming a member of Builders, a RailsBridge project, that connects volunteers with projects for 501c3 non-profits.

So far, I am volunteering in two projects: 1) Sunset PTA and GlamourGals Foundation.

The basic reasons I do this are:

  • Learn
  • Network
  • Give back

I learn asking questions or watching other team members doing stuff I don’t know. I discovered this way of learning is much faster than just reading and online searching. It cannot replace these of course, but it can help in addition to these methods of learning. Sometimes, when I learn something new from a fellow team member, I feel that it would be very difficult to discover it by myself.

When you volunteer to various projects, it is very easy to meet people with more or less the same mentality as yours. You get the opportunity to know them, open up your mind to new ways of thinking, choose who you like better and maybe create stronger relationships that may lead to other forms of cooperation in the future. This is extremely difficult to accomplish if one is only dedicated to their daily business because they don’t have many opportunities to network with new people.

Years and years, I have been receiving a lot of help from the Internet community in various forms: Forums, using free open source projects, becoming better by participating to various communities, educating myself, watching the improvement of commercial products because of the pressure of open source equivalent products, and more. I give back to the community by actively contributing and this makes me feel good. It also helps sustain the community and continue growing it.

This is going to be my second deed and I’ll keep posting any news that fall under this category.

A typical workflow for a team using Git

August 27th, 2009 Petros 2 comments

Lets assume you are in a team, working on a Rails project and you have chosen Git as your version control system. One way to complete a working cycle from pull to push is:

DISCLAIMER: There are more ways and many situations that are not described here. This is only a note to self that may also be useful to you.

Read more…

Categories: tips Tags: , , ,

Installing RSpec and Cucumber

July 11th, 2009 Petros No comments

Open your shell and,

For RSpec:

$ gem install rspec

For Cucumber:

$ gem install cucumber

Optionally, if you are on Windows, for color output you can also install Win32Console:

$ gem install win32console
Categories: tips Tags: , , , ,

Rails drop down lists

November 17th, 2008 Petros No comments

Sometimes you want to have a drop down list in your Rails application that contains both the items from a collection of model instances and some other items that are not coming from the collection.

Read more…

Categories: tips Tags: , ,

How to use Ruby on Rails in your day job

March 24th, 2008 Petros No comments

Disclaimer: I am biased.

A lot of noise started about the use of RoR in the enterprise. Can this be done? Technically, I don’t see a reason against it.

Programmers low in a company’s food chain would have to overcome some obstacles in order to push their favorite framework into everyday use.

Read more…

Categories: Uncategorized Tags: ,