Circle of Confusion

...I once was lost...
                          Limboville 居士

Saturday, March 25, 2006

 

Learning Rails

I've been trying to learn Ruby on Rails ever since this tutorial was posted in onlamp.com. Everytime I didn't get far because of one problem or another with setting up the enviroment under WinXP (Ruby, Gem, Rails, MySql). Then I saw the link to Rolling with Ruby on InstantRails. Ths solved the installation problem and I can finish the tutorial. But I don't like developement tools used in the tutorial. So I set out to find my ideal Rails development environment by doing this same tutorial several time using various setup. I determined the best is RadRails. So I try to do the tutorial from menory. Really, I haven't learn Ruby and I'm doing Rails. Seems a little backward. Then I run into this:



I have no clue what was happening. Since I did the tutorial so many times successfully, I know I was guilty of some mistakes. But what did I do wrong? Is this not like be your own psychics? After a long chase late night without success, I went to sleep at 2am because I was a zombie. Then this morning found the problem and it in here somewhere:
class RecipeController < ApplicationController
scaffold :recipe

def nrw
recipe = Recipe.new
@categories = Category.find_all
end

def create
@recipe = Recipe.new(@params['recipe'])
@recipe.date = Date.today
if @recipe.save
redirect_to :action => 'list'
else
render_action 'new'
end
end

def list
@recipes = Recipe.find_all
end

def list_debug
@recipes = Recipe.find_all
end

def edit
@recipe = Recipe.find(@params["id"])
@categories = Category.find_all
end
end


Viola!


ah ha, I found the mistake and It's a typo: I mistyped new as nrw.

I'm begining to learn Rails after ten so many years doing Java. I've forgot C++, many assembly. Just mostly dry confused J2EE. I wonder if this old dog can learn a new trick?

I tried many configurations in my search for my ideal development environment (I use a WinXP laptop):

- VMWare under WinXP running Linux doing rails development there
- Cygwin as a Unix shell to run rails command lines, various editor to do editing. I tied jEdit, notepad, Cream. While setup Cygwin, I discover rails app cannot connect to MySql, after some search around, I found out database.yml cannot use localhost, muust use 127.0.0.1 which for a tcp/ip connection.
- RadRails: at first creating an empty Rails project just do nothing. No error message or any indication what went wrong. Hmm, running generator show what's wrong: no Ruby.exe found. Ah, PATH problem. Onece I setup my environment variable PATH to contain ruby.exe, RadRails comes to life. Everything works!

Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home

Archives

August 2005   September 2005   October 2005   December 2005   January 2006   February 2006   March 2006   April 2006   December 2006   January 2008   February 2008   March 2008   October 2009  

This page is powered by Blogger. Isn't yours?

Subscribe to Comments [Atom]