soledad penadés
repeat 4[fd 100 rt 90]

Archive for the ‘ruby on rails’ Category

20051116 Fighting against ruby, rails, gems, php and apache on mac os x (and maybe something else I forget)

Last time I did some tests with rubyonrails, I made it over a pc box. This time I decided to give another try on installing everything on my laptop, as it's easier to start and stop ruby applications from my own console and not by running a VNC viewer and then accessing the windows command line, etc.

I must recognize that my previous attempts on installing rubyonrails, apache2 or php5 on this computer left the web thingie completely unusable here. Even the apache server which came installed with tiger by default was not working anymore. Not to mention my ridiculous achievement: install all of rubyonrails, see it worked and do some simple scaffoldings and then destroy it again by trying to not to use webrick and use apache2 instead (which is what led to not to have even normal apache running).

But maybe today was my day and for some strange stars and planets alignment I tried again and finally got everything working. So, just in case it's useful for someone:

I started here, on How To Install on OS X Tiger. Then on point 3 I switched and followed the instructions at Darwin Ports, untill I got rails installed.

Then I came back to How To Install on OS X Tiger, and then to mysql website to get latest installable version of mysql for mac Os. They have a very nice installation program which will do everything for you.

Once that was done, I created the ruby mysql binding with sudo gem install mysql — –with-mysql-dir=/usr/local/mysql, so ruby can communicate with the mysql database. (Some tutorials say you need to put the whole /usr/local/mysql 5.5.0… directory… but that's not exactly true as the mysql installation procedure creates a symbolic link called /usr/local/mysql)

After that I needed a way of launching the applications and the ports and so on. On Rails On Osx I found there was an application framework called Locomotive which could help me in doing that. In fact, I think it has everything that I neded and if I had find it before I shouldn't have had to do the points above, but hey that's a way of learning.

Installed that one, launched it (Applications -> Locomotive folder -> Locomotive) and then created a simple application just for testing (click the + sign, obvious!) and started it. I went to the browser and typed in http://localhost:3000/ and yeeeeeha! it was working: Congratulations, you've put Ruby on Rails!

But I hadn't had enough… now was time for … apache2 and php5! Luckily I found a very nice article that explained everything very clearly, at phpmac: Building and Installing Apache 2 and PHP 5.0.5 on Mac OS X 10.4 Tiger. The only thing that was a bit tricky was the download locations for the source code files, both for apache and php. as sometimes the mirrors weren't working at all. I presume one can simply download the files manually and uncompress them where needed, without having to use curl for getting them.

In any case it worked like a charm. After several long minutes compiling and making configurations and installs (still don't get how people loves to rebuild and recompile the kernel just for the sake of doing it), seems like I have managed to get both running!

Needless to say, I have no words for this. I'm deeply impressed :D

UPDATE 7 december 2005: this tutorial seems to be interesting too: how to set apache2 to be the default mac os X httpd server.

20051027 Some things I want to give a try…

You know, I am curious. I am always willing to learn things and all of that. These are the things I want to test:

  • CakePHP, recommended by Sin, a nice mix of php+ruby on rails design patterns. Maybe for cases in which you can't use rails… but do not want to keep coding the same once and once again… must have an indepth look…
  • Flock, that new collaborative browser. I started testing it a bit the other day but I am very busy these late weeks so I didn't configure it properly
  • Pong, for pinging different webs with your latest blog entries instead of pinging each engine separately,
  • and flash 8 and its new rendering features…. yummmmm
  • and rubyonrails… i want to continue with it!! (my latest improvement was installing it and playing a bit around)

So lots of things to get informed about… and so little time…! yay!

20051013 Ruby On Rails, round III: First real steps!

So I finally installed Ruby on Rails, and started playing around a bit with it!

It was quite easy with that tutorial I linked. And although I am not used yet to the Rails terminology, I am going to comment some things I liked:

  • It is meaningful. The models are real models, in the way that you specify their properties in their definitions, with no need to do weird tests and validations when manipulating them to demonstrate and keep the validity, as you do in php. For example, in php, if you want to have a 1:M relationship between two tables, you need to keep track of the uniqueness by yourself, helped by the database logic (although this case is really rare to find, unfortunately).

    Here in Ruby on Rails (RoR from now on) you just go to the model definition for A and say:

    has_many: table_for_B (was: has_many_and_belongs_to: table_for_B)

    And that way you specify that A has a 1:M relationship with B. More information in this example of an Access Control List.

    You can also have many to many relationships (M:M), which is specially useful for example in the case of crossed tables references. There's also a good tutorial for this topic here.

  • Another thing I liked is the naming. There's a convention about how to name things, so when a new programmer has to read code by other people, it's easier to catch up the idea than if you have to figure out if the table name for storing the users information is called Users, or User, or tbl_users, and so on.

    In the same style, no more wondering about how the primary key of a table is called. Id? table_id? cod? pk_id? Something simpler: id (absolutely lowercased).

    This not only helps the coders, but also the framework in itself. Seems like ActiveRecord (the subframework used for accessing database) uses that to link Models names and their persistence (i.e. the database).

  • Derived from the naming, comes the organization. All is organized always in the same fashion. When you first create the project (using a helper script), it creates all the files and folder structure for it. So you won't have a new programmer trying to reinvent the wheel and putting stylesheets in a css folder, instead of the old good stylesheets that you were using. Or img instead of images. And so on.
    Consequently and as you could expect, the models are in one folder, the controllers in other, etc…
  • And finally (by the moment) what is good is to find a nice community of people trying to learn and collaborate with others, sharing their pieces of code and wanting to understand how it works, not simply copying and pasting and expecting it to work. For example, if you go to the many to many relationships tutorial that I commented, you'll see how the people read the tutorial, and found errors while trying to put it into practice. And then they fixed the errors and let know the author so he can add the fixes to the original tutorial. Isn't it nice?

    I like the fact that there are not many script kiddies on this RoR scene, as they are in php. Call me elitist but I sometimes think computers are not for everybody.

More to come in next chapters ;)

UPDATE: An interesting comparison between J2EE and Ruby On Rails. If you have worked with J2EE, you'll remember nightmares as the controller mappings, the need for cleaning the cache if tomcat didn't detect properly you changed your code, etc… Take a look here and see what can be done with Rails which is overkilling if made with j2ee :-)

20051012 Ruby On Rails, round II

No, I haven't installed ruby on rails yet. I just found this super nice tutorial in two parts: Rolling with Ruby On Rails part I and Rolling with Ruby On Rails part II, by Curt Hibbs. These are in the same style that the famous video referred in my first post about ruby on rails, but step by step ;)

After seeing how we can have nice urls like http://mydomain/article/read/1, which map to a controller which maps to a database table in just few steps, I wonder why the hell I still keep using php and those old methods for coding…
In this language everything seems to make sense. There's a place for each thing and several naming rules which lead to quick, error free development. I mean, it's so obvious that you can't make an error.

Ahhh sin and herotyc are so right when they say they won't code in php again! Thanks for all the suggestions, mates!

I just need some time for installing this and starting playing a bit with all. Seeing the simple and meaningful syntax of ruby, I don't think it's going to take me too much time to start showing my prods to the public pleasure.

If you know more cool tutorials in that style just let them in the comments, thank you!

UPDATES:
This is another good tutorial: Really getting started in Rails. As it says, it explains the why which are not explained in the two first articles I pointed to.

Tutorial: How to do a todo list in rails.

20051007 Let's avoid reinventing the wheel…

After reading the other day that famous article, The Cathedral and the Bazaar, I started to have things running inside my mind… that is… thoughts mumbling and mumbling inside… Also I am working with few opensource projects related to cms publishing and editing, and I am a bit fed up of practices like the ones I commented on this article.

Also as I have commented several times, I want to get started on ruby on rails. I have some personal projects in mind that I think would benefit of having a good cms. If it is written with ruby on rails framework, it can be even better - a good moment to get started on it.

So the question is: do you guys know a good cms with ruby on rails?

I mean, a cms. Not a blogging software - it is different.

If there's not such a thing (I haven't found anything while searching for that on google and cms forums), I am interested in build one which would have features like these ones:

  • Clean separation of content and behaviour (should use templates)
  • The templates should be very similar to smarty style templates
  • Should generate clean (x)html
  • A visual online editor would be nice. Enough <tags> when coding ;)
  • Should not depend on any database (like using Adodb with php)
  • Easy to add features (the so called modules)
  • Object oriented programmed. Unable to define things in the global namespace, that is - complicated to break other modules code (although i think this can be immediate achieved if using ruby on rails)
  • Quick and efficient. I don't mean hacker code which is impossible to understand, though. Meaningful. Logical.
  • Something like the postnuke's permission system would be nice. It would be nicer if it was simpler and easier to understand.
  • Multilanguage support
  • Easy to maintain: install, uninstall, update
  • Connectivity with other systems: this is basicly things like rss, pings, ajax, etc… (i wanted to add a bit of buzzwords to this…). That would allow to play with the information of the cms with different interfaces, as for example flash.
  • A non programmer should be able to manage things in the system given a publisher account, without reading any manual. This stands for not using jargon or unintuitive interfaces.
  • And last but not least: I would like it to be documented in proper english, properly indexed. I want to understand the documentation, not to look for documentation to the documentation. And the documentation is not running an script and generating documents from the source code.

Any suggestion?

Any volunteer for this (if there's not such cms in the market)? Please do not say: I would help but I don't know how to code/design. Then just say: I would love to test it and provide you with the most delightful set of test reports ever seen. That is helpful.