Once you’re up and running with a working Ruby on Rails installation, here are a few other command line “scripts” to keep handy.
You may remember this from the other wiki page about installing RoR ( RoR Installation Cheat Sheet ) so here’s a quick recap at how to start your localhost server. You may have your Rails app running somewhere else, this is just an example.
At the C:\> type:cd rails_projects\NameOfMyApp
... hit enter, then at the C:\rails_projects\NameOfMyApp> type …
ruby script/server
... wait a second or two and you should see the server start spitting out a bunch of code in the Terminal window. This is good, now leave this window alone while you work on your new RoR app.
C:\>cd ra (tab)
... which gives me:
C:\>cd rails_projects
... then I type the dir separator and the first few letters of my next dir:
/Na (tab)
... which now gets me to:
C:\>cd rails_projects\NameOfMyApp
... hit enter and you’re now in the NameOfMyApp folder. Wheeeeeee!
Ruby needs a database to do the cool stuff it does, but don’t worry, at first you will not need to know MySQL. Ruby writes MySQL for you when the following is typed:
ruby script/generate model "modelName"
Be sure to go into PHPMyAdmin and double check that Ruby did this correctly. Go to http://localhost/phpmyadmin
Edit DB Migation means that you want to open your migration in a text editor and edit it.
db/migrate/modelName.rb
rake db:migrate
Create a controller with views attached, type this:
ruby script/generate controller "controllerName" "viewName1" "viewName2"
ruby script/generate scaffold "modelName" "controllerName"
For more info, Google it.