Mar 15

Heroku Heroku is a great project whose goal is to make Rail application development easy and painless. As we speak, the website is still in beta stage, but the creators are coming quickly to a paid model to be launched soon.

The project is the result of the collaboration of Adam Wiggins, James Lindenbaum, and Orion Henry. The three have made an incredible contribution to the Rails world by making it dead simple to deploy an application.

I signed up for a free account and got mine the next day. The control panel makes creating a project a snap, and you can quickly type in the details of your particular one. I had been working on my application for some time, so I had my source code handy. The only thing you need to do is tar the source code and import the zipped file into Heroku, like so:

Example: rm -rf myapp/{log,tmp}; tar czf myapp.tar.gz myapp/

That’s all.

Once you upload your code, Heroku does its thing, like change the database configuration file (they run on Postgres). After I was done uploading, a button called my attention and prompted me for running my migrations. I did, in the Ruby/Rails console provided, and a minute later I could test my application live.

The control panel gives you a tree view of your application structure, and you can use the on-line editor to make changes to the code. I have seen in the forums some people complain about the editor, but I think it’s great to make changes on the fly or if you happen to be away from your development box.

Since Heroku is still in beta stage, and the trio hasn’t yet worked on the payment methods, I can’t say how well the servers scale or perform. My application is destined to a small market, so I will never get close to even stressing the server. But I admit everything it’s pretty fast so far, specially given my lack of programming skills. I had a URL that I purchased through Yahoo! Small Business. I redirected the URL to Heroku’s own address and that worked wonders for me. Heroku is now giving sanctum quotas, which are faster bandwidth and more performance for people who need to go online now. I got mine pretty fast, but did not need to change CNAME by creating a sub-domain to use my own URL, which is the way Heroku prefers since it was easier to just redirect.

I hope the site continues to award free plans to those willing to test. The free quota is of 10 megabytes of space, and at the moment I don’t see a specific quota of bandwidth, but you don’t get always top performance (hey, it’s free!) I imagine for free development, in the near future there might be some limits, but I was very happy with the way the whole site performs so far.

I can’t stress again how easy it is to deploy. Just add DNS information and select from development to production status. That’s it! No need to worry about SVN, Capistrano, or other gems. Just tar the whole thing and upload it. So simple even I got it right!

Adam, James and Orion: thanks for the bottom of my heart. Free beer party if you are ever in Panama. You made a whole bunch of not so savvy Rails developer happy. But for what I see in the forums, there’s a whole bunch of very savvy developers using the project, so the impact might be even bigger than originally thought.

Check it Heroku and deploy the easy way!

written by Administrator

Jan 23

Rails rules!There is a new model for using scaffold in Rails 2.0. I had no idea that changed (although I did have to change lots of lines in my applications thanks to me not paying attention to deprecation messages from Mongrel.)

It took me some time to adjust to the changes, but now that I saw it, and learned it, it makes sense.

In the old days, when I needed a User database with say, name, email, and password, we would do first the model:

~> ruby script/generate model User

The second step is to edit the migration file like so:

class CreateUsers < ActiveRecord::Migration
# The User class is the doctors who use the system
def self.up
create_table :users do |t|
t.column :name, :string
t.column :password, :string
t.column :email, :string
end
end

def self.down
drop_table :users
end
end

The third step was to run the migration;

~> rake db:migrate

Finally, the last part was to run the scaffold code:

~> ruby script/generate scaffold User

That was the last step. By running the web server you could see your fast application all CRUD included. It was fast and fine, and got a ton of work done with little code.

So it took me a little by surprise that the Rails team decided to do away with scaffold, at least the old model, for a new one. It also made me Google for the new way to do things, but I was very please to try it out.

The new way involves knowing the structure of your model at the scaffold time, which I think it is a very simple requisite, since the model is the first thing everyone plans ahead of time. If we follow the sample above, the code would be

~> ruby script/generate scaffold User user:string email:string password:string
~> rake db:migrate

And that is all! The model and migration are constructed, along with the controller and all the necessary functions inside. It’s definitively easier than the previous way, and although it takes some time to get used to it, once you get the hang, it makes all the sense in the world.

written by Administrator