RoR: First Application
Trying to learning Ruby on Rails is driving me absolutely insane for a number of reasons:
- I’m using windows, and most of my peers are either on Ubuntu, mac, linux/unix, or what have you. I could install a virtual machine, partition another drive for linux, buy a mac… but I just want to get my feet wet, not shave a yak.
- I’ve gone through 5 or 6 tutorials including the ever famous cookbook and blog examples, and none of them have worked out. Again because I’m using InstantRails on windows. That, or I’m using an outdated version or Rails, or the tutorial is outdated because the commands that they are using are no longer supported in Rails 2.x.
- One such example is the Scaffold generator which all the tutorials seems to be fond of using. Which is impressive… but useless to a newbie because the tutorial boils down to: Put this line here, refresh the page and voila! Everything is generated automatically. Okay… Rails is awesome, I’m convinced, but WTF did it just do? It’s too soon to be showing tricks, especially when the tricks don’t work and I end up getting errors I don’t understand!
But hope is not lost. Ruby on Rails 2.1.x is an up-to-date tutorial that will guide you through everything. It gets into ground-level details without all the frills that Rails has to offer, teaching you the basics including Rails conventions and paradigms. It even explains how you can use Scaffold, but at the end when you have a grasp about how you could write the code on your own.
In addition RubyLearning.com was extremely helpful in getting me caught up on the Ruby language.
Even with this, I did not get by without cursing a few times.
Issues
- Error: “no such file to load — mysql”. The mysql driver was decoupled with Rails 2.2.*. You’ll have to reinstall it
gem install mysql. Be sure to restart the web server:CTRL+Con the server console followed byruby script/server. - It might be another “problem” with Rails 2.2.*, but when I generated models via
ruby script/generate model modelName, a migration was automatically generated called yyyymmdd_modelName.rb. So when I generated a migration explicitly , I got an error telling me a table already exists. Login to mysql using your username and password, (mysql -u rootin my case) and drop the tables and migration schema:drop table modelName; drop table schema_migrations. Follow-up by recreating the tables (this time, with all the required fields) using the migration scripts:rake db:migrate. - jEdit does not recognize *.html.erb as .*rhtml files, thus losing syntax highlight. Register the extension by going to
Utilities > Global Options > Editing. Under “Change settings for mode”, select rhtml. Uncheck “Use default settings”. In the “File name glob” field, add *.html.erb” or alternative, change it to “*.{rhtml,html.erb}”. Apply.
A few hours later, I have my first app!
Comments
Sensorial’Org » OLM: Progress Report (February 14th, 2009, 3:23 pm):
[…] 1: Got my first application up and running! It was a proud […]
Leave a Comment
January 11th, 2009
9:14 pm
Filed under 'Development, OLM'